Commit 430a39d7 authored by Marco Mattila's avatar Marco Mattila
Browse files

Modify pcbnew plot and zone dialogs. Policy fixes in dialog_copper_zone.

parent 1010601a
Loading
Loading
Loading
Loading
+34 −63
Original line number Diff line number Diff line
@@ -24,24 +24,19 @@
#define LAYER_BITMAP_SIZE_X 20
#define LAYER_BITMAP_SIZE_Y 10

/* the filter to show nets (default * "*").
 *  static to keep this pattern for an entire pcbnew session
 */
wxString dialog_copper_zone::m_netNameShowFilter( wxT( "*" ) );
// Initialize static member variables
wxString DIALOG_COPPER_ZONE::m_netNameShowFilter( wxT( "*" ) );
wxPoint DIALOG_COPPER_ZONE::prevPosition( -1, -1 );
wxSize DIALOG_COPPER_ZONE::prevSize;

wxPoint dialog_copper_zone::prevPosition( -1, -1 );
wxSize dialog_copper_zone::prevSize;


dialog_copper_zone::dialog_copper_zone( PCB_EDIT_FRAME* parent, ZONE_SETTING* zone_setting ) :
    dialog_copper_zone_base( parent )
DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE( PCB_EDIT_FRAME* parent, ZONE_SETTING* zone_setting ) :
    DIALOG_COPPER_ZONE_BASE( parent )
{
    m_Parent = parent;
    m_Config = wxGetApp().m_EDA_Config;
    m_Zone_Setting = zone_setting;
    m_NetSortingByPadCount = true;     /* false = alphabetic sort.
                                        *  true = pad count sort.
                                        */
    m_NetSortingByPadCount = true;     // false = alphabetic sort, true = pad count sort
    m_OnExitCode = ZONE_ABORT;

    SetReturnCode( ZONE_ABORT ); // Will be changed on buttons click
@@ -56,22 +51,24 @@ dialog_copper_zone::dialog_copper_zone( PCB_EDIT_FRAME* parent, ZONE_SETTING* zo
    m_layerSizer->Add( m_LayerSelectionCtrl, 1,
                       wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );

    // 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() );

    initDialog();

    GetSizer()->SetSizeHints( this );
    Center();

    if( prevPosition.x != -1 )
        SetSize( prevPosition.x, prevPosition.y,
                 prevSize.x, prevSize.y );
    else
        Center();
}


/*****************************************************************/
void dialog_copper_zone::initDialog()
/*****************************************************************/

// Initialise all dialog options and values in wxTextCtrl
void DIALOG_COPPER_ZONE::initDialog()
{
    BOARD* board = m_Parent->GetBoard();

@@ -202,15 +199,13 @@ void dialog_copper_zone::initDialog()
}


/********************************************************************/
void dialog_copper_zone::OnButtonCancelClick( wxCommandEvent& event )
/********************************************************************/
void DIALOG_COPPER_ZONE::OnButtonCancelClick( wxCommandEvent& event )
{
    Close( true );
}


void dialog_copper_zone::OnClose( wxCloseEvent& event )
void DIALOG_COPPER_ZONE::OnClose( wxCloseEvent& event )
{
    prevPosition = GetPosition();
    prevSize = GetSize();
@@ -218,7 +213,7 @@ void dialog_copper_zone::OnClose( wxCloseEvent& event )
}


void dialog_copper_zone::OnSize( wxSizeEvent& event )
void DIALOG_COPPER_ZONE::OnSize( wxSizeEvent& event )
{
    Layout();

@@ -228,7 +223,7 @@ void dialog_copper_zone::OnSize( wxSizeEvent& event )
}


void dialog_copper_zone::OnCornerSmoothingModeChoice( wxCommandEvent& event )
void DIALOG_COPPER_ZONE::OnCornerSmoothingModeChoice( wxCommandEvent& event )
{
    int selection = m_cornerSmoothingChoice->GetSelection();

@@ -254,16 +249,7 @@ void dialog_copper_zone::OnCornerSmoothingModeChoice( wxCommandEvent& event )
}


/********************************************************************************************/
bool dialog_copper_zone::AcceptOptions( bool aPromptForErrors, bool aUseExportableSetupOnly )
/********************************************************************************************/

/**
 * Function AcceptOptions(
 * @return false if incorrect options, true if Ok.
 * @param aPromptForErrors = true to prompt user on incorrectparams
 * @param aUseExportableSetupOnly = true to use exportable parametres only (used to export this setup to other zones)
 */
bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportableSetupOnly )
{
    switch( m_PadInZoneOpt->GetSelection() )
    {
@@ -365,8 +351,9 @@ bool dialog_copper_zone::AcceptOptions( bool aPromptForErrors, bool aUseExportab
    if( aUseExportableSetupOnly )
        return true;

    /* Get the layer selection for this zone */
    // Get the layer selection for this zone
    int ii = m_LayerSelectionCtrl->GetFirstSelected();

    if( ii < 0 && aPromptForErrors )
    {
        DisplayError( this, _( "No layer selected." ) );
@@ -375,8 +362,9 @@ bool dialog_copper_zone::AcceptOptions( bool aPromptForErrors, bool aUseExportab

    m_Zone_Setting->m_CurrentZone_Layer = m_LayerId[ii];

    /* Get the net name selection for this zone */
    // Get the net name selection for this zone
    ii = m_ListNetNameSelection->GetSelection();

    if( ii < 0 && aPromptForErrors )
    {
        DisplayError( this, _( "No net selected." ) );
@@ -395,7 +383,7 @@ bool dialog_copper_zone::AcceptOptions( bool aPromptForErrors, bool aUseExportab

    g_Zone_Default_Setting.m_NetcodeSelection = 0;

    /* Search net_code for this net, if a net was selected */
    // Search net_code for this net, if a net was selected
    if( m_ListNetNameSelection->GetSelection() > 0 )
    {
        NETINFO_ITEM* net = m_Parent->GetBoard()->FindNet( net_name );
@@ -407,9 +395,7 @@ bool dialog_copper_zone::AcceptOptions( bool aPromptForErrors, bool aUseExportab
}


/***************************************************************************/
void dialog_copper_zone::OnNetSortingOptionSelected( wxCommandEvent& event )
/***************************************************************************/
void DIALOG_COPPER_ZONE::OnNetSortingOptionSelected( wxCommandEvent& event )
{
    initListNetsParams();
    buildAvailableListOfNets();
@@ -424,9 +410,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();
    prevPosition = GetPosition();
@@ -437,9 +421,7 @@ void dialog_copper_zone::OnButtonOkClick( wxCommandEvent& event )
}


/******************************************************************************/
void dialog_copper_zone::ExportSetupToOtherCopperZones( wxCommandEvent& event )
/******************************************************************************/
void DIALOG_COPPER_ZONE::ExportSetupToOtherCopperZones( wxCommandEvent& event )
{
    prevPosition = GetPosition();
    prevSize = GetSize();
@@ -460,9 +442,7 @@ void dialog_copper_zone::ExportSetupToOtherCopperZones( wxCommandEvent& event )
}


/******************************************************************/
void dialog_copper_zone::OnPadsInZoneClick( wxCommandEvent& event )
/******************************************************************/
void DIALOG_COPPER_ZONE::OnPadsInZoneClick( wxCommandEvent& event )
{
    switch( m_PadInZoneOpt->GetSelection() )
    {
@@ -479,10 +459,7 @@ void dialog_copper_zone::OnPadsInZoneClick( wxCommandEvent& event )
}


/** init m_NetSortingByPadCount and m_NetFiltering values
 * according to m_NetDisplayOption selection
 */
void dialog_copper_zone::initListNetsParams()
void DIALOG_COPPER_ZONE::initListNetsParams()
{
    switch( m_NetDisplayOption->GetSelection() )
    {
@@ -509,15 +486,11 @@ void dialog_copper_zone::initListNetsParams()
}


/* 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 )
void DIALOG_COPPER_ZONE::OnRunFiltersButtonClick( wxCommandEvent& event )
{
    m_netNameShowFilter = m_ShowNetNameFilter->GetValue();

    // Ensure filtered option for nets:
    // Ensure filtered option for nets
    if( m_NetDisplayOption->GetSelection() == 0 )
        m_NetDisplayOption->SetSelection( 2 );
    else if( m_NetDisplayOption->GetSelection() == 1 )
@@ -527,7 +500,7 @@ void dialog_copper_zone::OnRunFiltersButtonClick( wxCommandEvent& event )
}


void dialog_copper_zone::buildAvailableListOfNets()
void DIALOG_COPPER_ZONE::buildAvailableListOfNets()
{
    wxArrayString listNetName;

@@ -577,18 +550,16 @@ void dialog_copper_zone::buildAvailableListOfNets()
}


wxBitmap dialog_copper_zone::makeLayerBitmap( int aColor )
wxBitmap DIALOG_COPPER_ZONE::makeLayerBitmap( int aColor )
{
    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;
+24 −2
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@

/* here is the derivated class from dialog_copper_zone_frame created by wxFormBuilder
 */
class dialog_copper_zone : public dialog_copper_zone_base
class DIALOG_COPPER_ZONE : public DIALOG_COPPER_ZONE_BASE
{
private:
    PCB_EDIT_FRAME*  m_Parent;
@@ -35,21 +35,43 @@ private:
    static wxSize   prevSize;

public:
    dialog_copper_zone( PCB_EDIT_FRAME* parent, ZONE_SETTING* zone_setting );
    DIALOG_COPPER_ZONE( PCB_EDIT_FRAME* parent, ZONE_SETTING* zone_setting );
private:

    /** 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 );
};
#endif      // #ifndef DIALOG_COPPER_ZONES
+247 −247
Original line number Diff line number Diff line
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 17 2010)
// C++ code generated with wxFormBuilder (version Nov 18 2010)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@@ -9,21 +9,21 @@

///////////////////////////////////////////////////////////////////////////

BEGIN_EVENT_TABLE( dialog_copper_zone_base, wxDialog )
	EVT_CLOSE( dialog_copper_zone_base::_wxFB_OnClose )
	EVT_SIZE( dialog_copper_zone_base::_wxFB_OnSize )
	EVT_CHOICE( ID_M_NETDISPLAYOPTION, dialog_copper_zone_base::_wxFB_OnNetSortingOptionSelected )
	EVT_TEXT_ENTER( ID_TEXTCTRL_NETNAMES_FILTER, dialog_copper_zone_base::_wxFB_OnRunFiltersButtonClick )
	EVT_TEXT_ENTER( ID_TEXTCTRL_NETNAMES_FILTER, dialog_copper_zone_base::_wxFB_OnRunFiltersButtonClick )
	EVT_BUTTON( wxID_APPLY_FILTERS, dialog_copper_zone_base::_wxFB_OnRunFiltersButtonClick )
	EVT_CHOICE( ID_CORNER_SMOOTHING, dialog_copper_zone_base::_wxFB_OnCornerSmoothingModeChoice )
	EVT_CHOICE( ID_M_PADINZONEOPT, dialog_copper_zone_base::_wxFB_OnPadsInZoneClick )
	EVT_BUTTON( wxID_BUTTON_EXPORT, dialog_copper_zone_base::_wxFB_ExportSetupToOtherCopperZones )
	EVT_BUTTON( wxID_OK, dialog_copper_zone_base::_wxFB_OnButtonOkClick )
	EVT_BUTTON( wxID_CANCEL, dialog_copper_zone_base::_wxFB_OnButtonCancelClick )
BEGIN_EVENT_TABLE( DIALOG_COPPER_ZONE_BASE, wxDialog )
	EVT_CLOSE( DIALOG_COPPER_ZONE_BASE::_wxFB_OnClose )
	EVT_SIZE( DIALOG_COPPER_ZONE_BASE::_wxFB_OnSize )
	EVT_CHOICE( ID_M_NETDISPLAYOPTION, DIALOG_COPPER_ZONE_BASE::_wxFB_OnNetSortingOptionSelected )
	EVT_TEXT_ENTER( ID_TEXTCTRL_NETNAMES_FILTER, DIALOG_COPPER_ZONE_BASE::_wxFB_OnRunFiltersButtonClick )
	EVT_TEXT_ENTER( ID_TEXTCTRL_NETNAMES_FILTER, DIALOG_COPPER_ZONE_BASE::_wxFB_OnRunFiltersButtonClick )
	EVT_BUTTON( wxID_APPLY_FILTERS, DIALOG_COPPER_ZONE_BASE::_wxFB_OnRunFiltersButtonClick )
	EVT_CHOICE( ID_CORNER_SMOOTHING, DIALOG_COPPER_ZONE_BASE::_wxFB_OnCornerSmoothingModeChoice )
	EVT_CHOICE( ID_M_PADINZONEOPT, DIALOG_COPPER_ZONE_BASE::_wxFB_OnPadsInZoneClick )
	EVT_BUTTON( wxID_BUTTON_EXPORT, DIALOG_COPPER_ZONE_BASE::_wxFB_ExportSetupToOtherCopperZones )
	EVT_BUTTON( wxID_OK, DIALOG_COPPER_ZONE_BASE::_wxFB_OnButtonOkClick )
	EVT_BUTTON( wxID_CANCEL, DIALOG_COPPER_ZONE_BASE::_wxFB_OnButtonCancelClick )
END_EVENT_TABLE()

dialog_copper_zone_base::dialog_copper_zone_base( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
DIALOG_COPPER_ZONE_BASE::DIALOG_COPPER_ZONE_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	
@@ -242,6 +242,6 @@ dialog_copper_zone_base::dialog_copper_zone_base( wxWindow* parent, wxWindowID i
	this->Layout();
}

dialog_copper_zone_base::~dialog_copper_zone_base()
DIALOG_COPPER_ZONE_BASE::~DIALOG_COPPER_ZONE_BASE()
{
}
+3222 −3222
Original line number Diff line number Diff line
@@ -48,14 +48,14 @@
            <property name="font"></property>
            <property name="gripper">0</property>
            <property name="hidden">0</property>
            <property name="id">wxID_ANY</property>
            <property name="id">ID_DIALOG_COPPER_ZONE_BASE</property>
            <property name="layer"></property>
            <property name="maximize_button">0</property>
            <property name="maximum_size"></property>
            <property name="minimize_button">0</property>
            <property name="minimum_size"></property>
            <property name="moveable">1</property>
            <property name="name">dialog_copper_zone_base</property>
            <property name="name">DIALOG_COPPER_ZONE_BASE</property>
            <property name="pane_border">1</property>
            <property name="pane_position"></property>
            <property name="pane_size"></property>
+126 −125
Original line number Diff line number Diff line
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 17 2010)
// C++ code generated with wxFormBuilder (version Nov 18 2010)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@@ -27,9 +27,9 @@
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
/// 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()
	private:
@@ -49,7 +49,8 @@ class dialog_copper_zone_base : public wxDialog
	protected:
		enum
		{
			ID_NETNAME_SELECTION = 1000,
			ID_DIALOG_COPPER_ZONE_BASE = 1000,
			ID_NETNAME_SELECTION,
			ID_M_NETDISPLAYOPTION,
			ID_TEXTCTRL_NETNAMES_FILTER,
			wxID_APPLY_FILTERS,
@@ -117,8 +118,8 @@ class dialog_copper_zone_base : public wxDialog
	
	public:
		
		dialog_copper_zone_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Zone Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 550,500 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); 
		~dialog_copper_zone_base();
		DIALOG_COPPER_ZONE_BASE( wxWindow* parent, wxWindowID id = ID_DIALOG_COPPER_ZONE_BASE, const wxString& title = _("Zone Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 550,500 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); 
		~DIALOG_COPPER_ZONE_BASE();
	
};

Loading