Commit 492c75bd authored by jean-pierre charras's avatar jean-pierre charras

Enhancement in copper zones dialog, useful for large boards having a lot of nets

parents 84ce064e 027c4cca
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
#include "dialog_copper_zones.h" #include "dialog_copper_zones.h"
wxString dialog_copper_zone::m_netNameShowFilter("*"); /* the filter to show nets (default * "*").
* static to keep this pattern for an entire pcbnew session
*/
/************************************************************************************************/ /************************************************************************************************/
dialog_copper_zone::dialog_copper_zone( WinEDA_PcbFrame* parent, ZONE_SETTING* zone_setting ) : dialog_copper_zone::dialog_copper_zone( WinEDA_PcbFrame* parent, ZONE_SETTING* zone_setting ) :
...@@ -31,11 +34,6 @@ dialog_copper_zone::dialog_copper_zone( WinEDA_PcbFrame* parent, ZONE_SETTING* z ...@@ -31,11 +34,6 @@ dialog_copper_zone::dialog_copper_zone( WinEDA_PcbFrame* parent, ZONE_SETTING* z
m_NetSorting = 1; // 0 = alphabetic sort, 1 = pad count sort, and filtering net names m_NetSorting = 1; // 0 = alphabetic sort, 1 = pad count sort, and filtering net names
m_OnExitCode = ZONE_ABORT; m_OnExitCode = ZONE_ABORT;
if( m_Config )
{
m_NetSorting = m_Config->Read( ZONE_NET_SORT_OPTION_KEY, 1l );
}
SetReturnCode( ZONE_ABORT ); // Will be changed on buttons click SetReturnCode( ZONE_ABORT ); // Will be changed on buttons click
initDialog(); initDialog();
...@@ -46,7 +44,7 @@ dialog_copper_zone::dialog_copper_zone( WinEDA_PcbFrame* parent, ZONE_SETTING* z ...@@ -46,7 +44,7 @@ dialog_copper_zone::dialog_copper_zone( WinEDA_PcbFrame* parent, ZONE_SETTING* z
/*****************************************************************/ /*****************************************************************/
void dialog_copper_zone::initDialog( ) void dialog_copper_zone::initDialog()
/*****************************************************************/ /*****************************************************************/
// Initialise all dialog options and values in wxTextCtrl // Initialise all dialog options and values in wxTextCtrl
...@@ -148,57 +146,22 @@ void dialog_copper_zone::initDialog( ) ...@@ -148,57 +146,22 @@ void dialog_copper_zone::initDialog( )
m_LayerSelectionCtrl->SetSelection( ii ); m_LayerSelectionCtrl->SetSelection( ii );
} }
m_NetSortingOption->SetSelection( m_NetSorting ); wxString netNameDoNotShowFilter = wxT( "N-*" );
wxString NetNameFilter = wxT( "N_0*" );
if( m_Config ) if( m_Config )
{ {
NetNameFilter = int opt = m_Config->Read( ZONE_NET_SORT_OPTION_KEY, 1l );
m_Config->Read( ZONE_NET_FILTER_STRING_KEY ); m_NetDisplayOption->SetSelection( opt );
m_Config->Read( ZONE_NET_FILTER_STRING_KEY, netNameDoNotShowFilter );
} }
else
m_NetDisplayOption->SetSelection( 1 );
// Build list of nets: m_ShowNetNameFilter->SetValue(m_netNameShowFilter);
m_NetNameFilter->SetValue( NetNameFilter ); initListNetsParams();
wxArrayString ListNetName;
m_Parent->GetBoard()->ReturnSortedNetnamesList(
ListNetName,
m_NetSorting == 0 ? false : true );
if( m_NetSorting != 0 )
{
wxString Filter = m_NetNameFilter->GetValue();
for( unsigned ii = 0; ii < ListNetName.GetCount(); ii++ )
{
if( ListNetName[ii].Matches( Filter.GetData() ) )
{
ListNetName.RemoveAt( ii );
ii--;
}
}
}
ListNetName.Insert( wxT( "<no net>" ), 0 );
m_ListNetNameSelection->InsertItems( ListNetName, 0 );
// Select net:
int net_select = m_Zone_Setting->m_NetcodeSelection;
if( net_select > 0 ) // Build list of nets:
{ m_DoNotShowNetNameFilter->SetValue( netNameDoNotShowFilter );
NETINFO_ITEM* equipot = m_Parent->GetBoard()->FindNet( net_select ); buildAvailableListOfNets();
if( equipot ) // Search net in list and select it
{
for( unsigned ii = 0; ii < ListNetName.GetCount(); ii++ )
{
if( ListNetName[ii] == equipot->GetNetname() )
{
m_ListNetNameSelection->SetSelection( ii );
m_ListNetNameSelection->EnsureVisible( ii );
break;
}
}
}
}
} }
...@@ -258,10 +221,11 @@ bool dialog_copper_zone::AcceptOptions( bool aPromptForErrors, bool aUseExportab ...@@ -258,10 +221,11 @@ bool dialog_copper_zone::AcceptOptions( bool aPromptForErrors, bool aUseExportab
{ {
m_Config->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY, m_Config->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY,
(long) m_Zone_Setting->m_Zone_HatchingStyle ); (long) m_Zone_Setting->m_Zone_HatchingStyle );
wxString Filter = m_NetNameFilter->GetValue(); wxString Filter = m_DoNotShowNetNameFilter->GetValue();
m_Config->Write( ZONE_NET_FILTER_STRING_KEY, Filter ); m_Config->Write( ZONE_NET_FILTER_STRING_KEY, Filter );
} }
m_netNameShowFilter = m_ShowNetNameFilter->GetValue();
m_Zone_Setting->m_FillMode = (m_FillModeCtrl->GetSelection() == 0) ? 0 : 1; m_Zone_Setting->m_FillMode = (m_FillModeCtrl->GetSelection() == 0) ? 0 : 1;
wxString txtvalue = m_ZoneClearanceCtrl->GetValue(); wxString txtvalue = m_ZoneClearanceCtrl->GetValue();
...@@ -365,50 +329,16 @@ bool dialog_copper_zone::AcceptOptions( bool aPromptForErrors, bool aUseExportab ...@@ -365,50 +329,16 @@ bool dialog_copper_zone::AcceptOptions( bool aPromptForErrors, bool aUseExportab
void dialog_copper_zone::OnNetSortingOptionSelected( wxCommandEvent& event ) void dialog_copper_zone::OnNetSortingOptionSelected( wxCommandEvent& event )
/***************************************************************************/ /***************************************************************************/
{ {
wxArrayString ListNetName; initListNetsParams();
buildAvailableListOfNets();
m_NetSorting = m_NetSortingOption->GetSelection(); m_netNameShowFilter = m_ShowNetNameFilter->GetValue();
m_Parent->GetBoard()->ReturnSortedNetnamesList(
ListNetName, m_NetSorting == 0 ? false : true );
if( m_NetSorting != 0 )
{
wxString Filter = m_NetNameFilter->GetValue();
for( unsigned ii = 0; ii < ListNetName.GetCount(); ii++ )
{
if( ListNetName[ii].Matches( Filter.GetData() ) )
{
ListNetName.RemoveAt( ii );
ii--;
}
}
}
m_ListNetNameSelection->Clear();
m_ListNetNameSelection->InsertItems( ListNetName, 0 );
if( m_Config ) if( m_Config )
{ {
m_Config->Write( ZONE_NET_SORT_OPTION_KEY, (long) m_NetSorting ); m_Config->Write( ZONE_NET_SORT_OPTION_KEY, (long) m_NetDisplayOption->GetSelection() );
wxString Filter = m_NetNameFilter->GetValue(); wxString Filter = m_DoNotShowNetNameFilter->GetValue();
m_Config->Write( ZONE_NET_FILTER_STRING_KEY, Filter ); m_Config->Write( ZONE_NET_FILTER_STRING_KEY, Filter );
} }
// Select and display current zone net name in listbox:
int net_select = m_Zone_Setting->m_NetcodeSelection;
if( net_select > 0 )
{
NETINFO_ITEM* equipot = m_Parent->GetBoard()->FindNet( net_select );
if( equipot ) // Search net in list and select it
{
for( unsigned ii = 0; ii < ListNetName.GetCount(); ii++ )
{
if( ListNetName[ii] == equipot->GetNetname() )
{
m_ListNetNameSelection->SetSelection( ii );
m_ListNetNameSelection->EnsureVisible( ii );
break;
}
}
}
}
} }
...@@ -416,6 +346,7 @@ void dialog_copper_zone::OnNetSortingOptionSelected( wxCommandEvent& event ) ...@@ -416,6 +346,7 @@ void dialog_copper_zone::OnNetSortingOptionSelected( wxCommandEvent& event )
void dialog_copper_zone::OnButtonOkClick( wxCommandEvent& event ) void dialog_copper_zone::OnButtonOkClick( wxCommandEvent& event )
/*****************************************************************/ /*****************************************************************/
{ {
m_netNameShowFilter = m_ShowNetNameFilter->GetValue();
if( AcceptOptions( true ) ) if( AcceptOptions( true ) )
EndModal( ZONE_OK ); EndModal( ZONE_OK );
} }
...@@ -458,3 +389,100 @@ void dialog_copper_zone::OnPadsInZoneClick( wxCommandEvent& event ) ...@@ -458,3 +389,100 @@ void dialog_copper_zone::OnPadsInZoneClick( wxCommandEvent& event )
break; break;
} }
} }
/** init m_NetSorting and m_NetFiltering values
* according to m_NetDisplayOption selection
*/
void dialog_copper_zone::initListNetsParams()
{
switch( m_NetDisplayOption->GetSelection() )
{
case 0:
m_NetSorting = true;
m_NetFiltering = false;
break;
case 1:
m_NetSorting = false;
m_NetFiltering = false;
break;
case 2:
m_NetSorting = true;
m_NetFiltering = true;
break;
case 3:
m_NetSorting = false;
m_NetFiltering = true;
break;
}
}
/* Called when clicking on Apply Filter button
* Rebuild the list of nets with the currents filters settings.
* If the net display options is not a filtered option, force this option
*/
void dialog_copper_zone::OnRunFiltersButtonClick( wxCommandEvent& event )
{
m_netNameShowFilter = m_ShowNetNameFilter->GetValue();
// Ensure filtered option for nets:
if( m_NetDisplayOption->GetSelection() == 0 )
m_NetDisplayOption->SetSelection( 2 );
else if( m_NetDisplayOption->GetSelection() == 1 )
m_NetDisplayOption->SetSelection( 3 );
initListNetsParams();
buildAvailableListOfNets();
}
void dialog_copper_zone::buildAvailableListOfNets()
{
wxArrayString listNetName;
m_Parent->GetBoard()->ReturnSortedNetnamesList(
listNetName, m_NetSorting == 0 ? false : true );
if( m_NetFiltering )
{
wxString doNotShowFilter = m_DoNotShowNetNameFilter->GetValue();
wxString ShowFilter = m_ShowNetNameFilter->GetValue();
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--;
}
}
}
m_ListNetNameSelection->Clear();
listNetName.Insert( wxT( "<no net>" ), 0 );
m_ListNetNameSelection->InsertItems( listNetName, 0 );
// Ensure current select net for the zone is visible:
int net_select = m_Zone_Setting->m_NetcodeSelection;
if( net_select > 0 )
{
NETINFO_ITEM* equipot = m_Parent->GetBoard()->FindNet( net_select );
if( equipot ) // Search net in list and select it
{
for( unsigned ii = 0; ii < listNetName.GetCount(); ii++ )
{
if( listNetName[ii] == equipot->GetNetname() )
{
m_ListNetNameSelection->SetSelection( ii );
m_ListNetNameSelection->EnsureVisible( ii );
break;
}
}
}
}
}
...@@ -17,20 +17,26 @@ private: ...@@ -17,20 +17,26 @@ private:
* ZONE_EXPORT_VALUES if values are exported to others zones * ZONE_EXPORT_VALUES if values are exported to others zones
*/ */
ZONE_SETTING* m_Zone_Setting; ZONE_SETTING* m_Zone_Setting;
long m_NetSorting; long m_NetSorting;
int m_LayerId[LAYER_COUNT]; // Handle the real layer number from layer name position in m_LayerSelectionCtrl long m_NetFiltering;
int m_LayerId[LAYER_COUNT]; // 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
*/
public: public:
dialog_copper_zone( WinEDA_PcbFrame* parent, ZONE_SETTING* zone_setting ); dialog_copper_zone( WinEDA_PcbFrame* parent, ZONE_SETTING* zone_setting );
private: private:
void initDialog( ); void initDialog();
void OnButtonOkClick( wxCommandEvent& event ); void OnButtonOkClick( wxCommandEvent& event );
void OnButtonCancelClick( wxCommandEvent& event ); void OnButtonCancelClick( wxCommandEvent& event );
bool AcceptOptions( bool aPromptForErrors, bool aUseExportableSetupOnly = false ); bool AcceptOptions( bool aPromptForErrors, bool aUseExportableSetupOnly = false );
void OnNetSortingOptionSelected( wxCommandEvent& event ); void OnNetSortingOptionSelected( wxCommandEvent& event );
void ExportSetupToOtherCopperZones( wxCommandEvent& event ); void ExportSetupToOtherCopperZones( wxCommandEvent& event );
void OnPadsInZoneClick( wxCommandEvent& event ); void OnPadsInZoneClick( wxCommandEvent& event );
void OnRunFiltersButtonClick( wxCommandEvent& event );
void buildAvailableListOfNets();
void initListNetsParams();
}; };
#endif // #ifndef DIALOG_COPPER_ZONES #endif // #ifndef DIALOG_COPPER_ZONES
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008) // C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_copper_zones_base__ #ifndef __dialog_copper_zones_base__
#define __dialog_copper_zones_base__ #define __dialog_copper_zones_base__
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/radiobox.h> #include <wx/radiobox.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/font.h> #include <wx/font.h>
#include <wx/colour.h> #include <wx/colour.h>
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/statbox.h> #include <wx/statbox.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/listbox.h> #include <wx/listbox.h>
#include <wx/dialog.h> #include <wx/dialog.h>
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class dialog_copper_zone_base /// Class dialog_copper_zone_base
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class dialog_copper_zone_base : public wxDialog class dialog_copper_zone_base : public wxDialog
{ {
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
private: private:
// Private event handlers // Private event handlers
void _wxFB_OnPadsInZoneClick( wxCommandEvent& event ){ OnPadsInZoneClick( event ); } void _wxFB_OnPadsInZoneClick( wxCommandEvent& event ){ OnPadsInZoneClick( event ); }
void _wxFB_ExportSetupToOtherCopperZones( wxCommandEvent& event ){ ExportSetupToOtherCopperZones( event ); } void _wxFB_ExportSetupToOtherCopperZones( wxCommandEvent& event ){ ExportSetupToOtherCopperZones( event ); }
void _wxFB_OnButtonOkClick( wxCommandEvent& event ){ OnButtonOkClick( event ); } void _wxFB_OnButtonOkClick( wxCommandEvent& event ){ OnButtonOkClick( event ); }
void _wxFB_OnButtonCancelClick( wxCommandEvent& event ){ OnButtonCancelClick( event ); } void _wxFB_OnButtonCancelClick( wxCommandEvent& event ){ OnButtonCancelClick( event ); }
void _wxFB_OnNetSortingOptionSelected( wxCommandEvent& event ){ OnNetSortingOptionSelected( event ); } void _wxFB_OnNetSortingOptionSelected( wxCommandEvent& event ){ OnNetSortingOptionSelected( event ); }
void _wxFB_OnRunFiltersButtonClick( wxCommandEvent& event ){ OnRunFiltersButtonClick( event ); }
protected:
enum protected:
{ enum
ID_RADIOBOX_FILL_MODE_SELECTION = 1000, {
wxID_ARC_APPROX, ID_RADIOBOX_FILL_MODE_SELECTION = 1000,
wxID_PADS_IN_ZONE_OPTIONS, wxID_ARC_APPROX,
wxID_ANTIPAD_SIZE, wxID_PADS_IN_ZONE_OPTIONS,
wxID_COPPER_BRIDGE_VALUE, wxID_ANTIPAD_SIZE,
ID_RADIOBOX_OUTLINES_OPTION, wxID_COPPER_BRIDGE_VALUE,
wxID_BUTTON_EXPORT, ID_RADIOBOX_OUTLINES_OPTION,
ID_NET_SORTING_OPTION, wxID_BUTTON_EXPORT,
ID_TEXTCTRL_NETNAMES_FILTER, ID_NET_SORTING_OPTION,
ID_NETNAME_SELECTION, ID_TEXTCTRL_NETNAMES_FILTER,
ID_LAYER_CHOICE, ID_NETNAME_SELECTION,
}; ID_LAYER_CHOICE,
};
wxRadioBox* m_FillModeCtrl;
wxRadioBox* m_ArcApproximationOpt; wxRadioBox* m_FillModeCtrl;
wxRadioBox* m_PadInZoneOpt; wxRadioBox* m_ArcApproximationOpt;
wxStaticText* m_AntipadSizeText; wxRadioBox* m_PadInZoneOpt;
wxTextCtrl* m_AntipadSizeValue; wxStaticText* m_AntipadSizeText;
wxStaticText* m_CopperBridgeWidthText; wxTextCtrl* m_AntipadSizeValue;
wxTextCtrl* m_CopperWidthValue; wxStaticText* m_CopperBridgeWidthText;
wxTextCtrl* m_CopperWidthValue;
wxRadioBox* m_OrientEdgesOpt;
wxRadioBox* m_OutlineAppearanceCtrl; wxRadioBox* m_OrientEdgesOpt;
wxStaticText* m_ClearanceValueTitle; wxRadioBox* m_OutlineAppearanceCtrl;
wxTextCtrl* m_ZoneClearanceCtrl; wxStaticText* m_ClearanceValueTitle;
wxStaticText* m_MinThicknessValueTitle; wxTextCtrl* m_ZoneClearanceCtrl;
wxTextCtrl* m_ZoneMinThicknessCtrl; wxStaticText* m_MinThicknessValueTitle;
wxTextCtrl* m_ZoneMinThicknessCtrl;
wxButton* m_ExportSetupButton;
wxButton* m_OkButton; wxButton* m_ExportSetupButton;
wxButton* m_ButtonCancel; wxButton* m_OkButton;
wxButton* m_ButtonCancel;
wxRadioBox* m_NetSortingOption;
wxStaticText* m_staticText5; wxRadioBox* m_NetDisplayOption;
wxTextCtrl* m_NetNameFilter; wxStaticText* m_staticText5;
wxStaticText* m_staticText2; wxTextCtrl* m_DoNotShowNetNameFilter;
wxListBox* m_ListNetNameSelection; wxStaticText* m_staticText51;
wxStaticText* m_staticText3; wxTextCtrl* m_ShowNetNameFilter;
wxListBox* m_LayerSelectionCtrl; wxButton* m_buttonRunFilter;
wxStaticText* m_staticText2;
// Virtual event handlers, overide them in your derived class wxListBox* m_ListNetNameSelection;
virtual void OnPadsInZoneClick( wxCommandEvent& event ){ event.Skip(); } wxStaticText* m_staticText3;
virtual void ExportSetupToOtherCopperZones( wxCommandEvent& event ){ event.Skip(); } wxListBox* m_LayerSelectionCtrl;
virtual void OnButtonOkClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonCancelClick( wxCommandEvent& event ){ event.Skip(); } // Virtual event handlers, overide them in your derived class
virtual void OnNetSortingOptionSelected( wxCommandEvent& event ){ event.Skip(); } virtual void OnPadsInZoneClick( wxCommandEvent& event ){ event.Skip(); }
virtual void ExportSetupToOtherCopperZones( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonOkClick( wxCommandEvent& event ){ event.Skip(); }
public: virtual void OnButtonCancelClick( wxCommandEvent& event ){ event.Skip(); }
dialog_copper_zone_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Fill Zones Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 566,582 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); virtual void OnNetSortingOptionSelected( wxCommandEvent& event ){ event.Skip(); }
~dialog_copper_zone_base(); virtual void OnRunFiltersButtonClick( wxCommandEvent& event ){ event.Skip(); }
};
public:
#endif //__dialog_copper_zones_base__ dialog_copper_zone_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Fill Zones Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 566,582 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~dialog_copper_zone_base();
};
#endif //__dialog_copper_zones_base__
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