Pcbnew: fix Bug #1304418 . Fix also a related issue which crashes Pcbnew in some corner cases.

(for instance, when a footprint from the currently edited board is loaded in the footprint editor, and when the board is cleared or reloaded)
In footprint editor, the net names are no more shown od modifiable (becuase the footprint editor does not know anything about net names.
This change should allow the changes planned in pcbnew.
This commit is contained in:
jean-pierre charras 2014-04-24 20:54:49 +02:00
parent b427aa49c1
commit 9c1f6b7307
10 changed files with 703 additions and 456 deletions

View File

@ -29,16 +29,9 @@ dialog_about::dialog_about(wxWindow *parent, AboutAppInfo& appInfo)
m_staticTextBuildVersion->SetLabel( info.GetBuildVersion() );
m_staticTextLibVersion->SetLabel( info.GetLibVersion() );
/* Affects m_titlepanel the parent of some wxStaticText.
* Changing the text afterwards makes it under Windows necessary to call 'Layout()'
* so that the new text gets properly layout.
*/
/* m_staticTextCopyright->GetParent()->Layout();
m_staticTextBuildVersion->GetParent()->Layout();
m_staticTextLibVersion->GetParent()->Layout();
*/
DeleteNotebooks();
CreateNotebooks();
GetSizer()->SetSizeHints(this);
m_auiNotebook->Update();
SetFocus();

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 8 2010)
// C++ code generated with wxFormBuilder (version Nov 6 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -46,11 +46,13 @@ dialog_about_base::dialog_about_base( wxWindow* parent, wxWindowID id, const wxS
m_staticTextLibVersion->Wrap( -1 );
b_apptitleSizer->Add( m_staticTextLibVersion, 0, wxALIGN_CENTER|wxBOTTOM|wxLEFT|wxRIGHT, 5 );
bSizer3->Add( b_apptitleSizer, 10, wxEXPAND, 5 );
bSizer3->Add( 0, 0, 2, wxEXPAND, 5 );
bSizer1->Add( bSizer3, 0, wxEXPAND, 5 );
wxStaticLine* m_staticline1;
@ -67,6 +69,7 @@ dialog_about_base::dialog_about_base( wxWindow* parent, wxWindowID id, const wxS
m_buttonOK->SetDefault();
bSizer1->Add( m_buttonOK, 0, wxALIGN_CENTER|wxALL, 5 );
this->SetSizer( bSizer1 );
this->Layout();

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,16 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 8 2010)
// C++ code generated with wxFormBuilder (version Nov 6 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_about_base__
#define __dialog_about_base__
#ifndef __DIALOG_ABOUT_BASE_H__
#define __DIALOG_ABOUT_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
@ -37,13 +38,11 @@ class dialog_about_base : public wxDialog
wxButton* m_buttonOK;
protected:
wxStaticBitmap* m_bitmapApp;
wxStaticText* m_staticTextAppTitle;
wxStaticText* m_staticTextCopyright;
wxStaticText* m_staticTextBuildVersion;
wxStaticText* m_staticTextLibVersion;
wxAuiNotebook* m_auiNotebook;
// Virtual event handlers, overide them in your derived class
@ -53,9 +52,9 @@ class dialog_about_base : public wxDialog
public:
dialog_about_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("About..."), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 750,350 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSTAY_ON_TOP );
dialog_about_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("About..."), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 750,450 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSTAY_ON_TOP );
~dialog_about_base();
};
#endif //__dialog_about_base__
#endif //__DIALOG_ABOUT_BASE_H__

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -234,7 +234,7 @@ private:
/**
* Class NETINFO
* Class NETINFO_LIST
* is a container class for NETINFO_ITEM elements, which are the nets. That makes
* this class a container for the nets.
*/

View File

@ -1,8 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License

View File

@ -499,10 +499,10 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
wxPoint tpos0 = shape_pos; // Position of the centre of text
wxPoint tpos = tpos0;
wxSize AreaSize; // size of text area, normalized to AreaSize.y < AreaSize.x
int shortname_len = GetShortNetname().Len();
int shortname_len = 0;
if( !aDrawInfo.m_Display_netname )
shortname_len = 0;
if( aDrawInfo.m_Display_netname )
shortname_len = GetShortNetname().Len();
if( GetShape() == PAD_CIRCLE )
angle = 0;

View File

@ -97,11 +97,17 @@ private:
PCB_BASE_FRAME* m_parent;
D_PAD* m_currentPad; // pad currently being edited
D_PAD* m_dummyPad; // a working copy used to show changes
BOARD* m_board;
D_PAD& m_padMaster;
D_PAD* m_padMaster; // The pad used to create new pads in board or
// footprint editor
BOARD* m_board; // the main board: this is the board handled by
// the PCB editor, if running or the dummy
// board used by the footprint editor
// (could happen when the Footprint editor will be run
// alone, outside the board editor
bool m_isFlipped; // true if the parent footprint (therefore pads) is flipped (mirrored)
// in this case, some Y coordinates values must be negated
bool m_canUpdate;
bool m_canEditNetName; // true only if the called is the board editor
private:
void initValues();
@ -139,25 +145,31 @@ private:
void PadPropertiesAccept( wxCommandEvent& event );
};
void PCB_BASE_FRAME::InstallPadOptionsFrame( D_PAD* aPad )
{
DIALOG_PAD_PROPERTIES dlg( this, aPad );
dlg.ShowModal();
}
DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aPad ) :
DIALOG_PAD_PROPERTIES_BASE( aParent ),
// use aParent's parent, which is the original BOARD, not the dummy module editor BOARD,
// since FOOTPRINT_EDIT_FRAME::GetDesignSettings() is tricked out to use the PCB_EDIT_FRAME's
// BOARD, not its own BOARD.
m_padMaster( aParent->GetDesignSettings().m_Pad_Master )
DIALOG_PAD_PROPERTIES_BASE( aParent )
{
m_canUpdate = false;
m_parent = aParent;
m_currentPad = aPad; // aPad can be NULL, if the dialog is called
// from the module editor to set default pad characteristics
m_board = m_parent->GetBoard();
m_padMaster = &m_parent->GetDesignSettings().m_Pad_Master;
m_dummyPad = new D_PAD( (MODULE*) NULL );
if( aPad )
m_dummyPad->Copy( aPad );
else
m_dummyPad->Copy( &m_padMaster );
else // We are editing a "master" pad, i.e. a pad used to create new pads
m_dummyPad->Copy( m_padMaster );
initValues();
@ -238,19 +250,16 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
}
void PCB_BASE_FRAME::InstallPadOptionsFrame( D_PAD* aPad )
{
DIALOG_PAD_PROPERTIES dlg( this, aPad );
dlg.ShowModal();
}
void DIALOG_PAD_PROPERTIES::initValues()
{
wxString msg;
double angle;
// Disable pad net name wxTextCtrl if the caller is the footprint editor
// because nets are living only in the board managed by the board editor
m_canEditNetName = m_parent->IsType( FRAME_PCB );
// Setup layers names from board
// Should be made first, before calling m_rbCopperLayersSel->SetSelection()
m_rbCopperLayersSel->SetString( 0, m_board->GetLayerName( LAYER_N_FRONT ) );
@ -471,7 +480,7 @@ void DIALOG_PAD_PROPERTIES::initValues()
bool enable = m_dummyPad->GetAttribute() != PAD_HOLE_NOT_PLATED;
m_PadNumCtrl->Enable( enable );
m_PadNetNameCtrl->Enable( enable );
m_PadNetNameCtrl->Enable( m_canEditNetName && enable && m_currentPad != NULL );
m_LengthPadToDieCtrl->Enable( enable );
if( m_dummyPad->GetDrillShape() != PAD_DRILL_OBLONG )
@ -593,7 +602,7 @@ void DIALOG_PAD_PROPERTIES::PadOrientEvent( wxCommandEvent& event )
void DIALOG_PAD_PROPERTIES::PadTypeSelected( wxCommandEvent& event )
{
unsigned ii = m_PadType->GetSelection();
unsigned ii = m_PadType->GetSelection();
if( ii >= NBTYPES ) // catches < 0 also
ii = 0;
@ -614,7 +623,7 @@ void DIALOG_PAD_PROPERTIES::PadTypeSelected( wxCommandEvent& event )
// (disable for NPTH pads (mechanical pads)
bool enable = ii != 3;
m_PadNumCtrl->Enable( enable );
m_PadNetNameCtrl->Enable( enable );
m_PadNetNameCtrl->Enable( m_canEditNetName && enable && m_currentPad != NULL );
m_LengthPadToDieCtrl->Enable( enable );
}
@ -752,7 +761,9 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
bool rastnestIsChanged = false;
int isign = m_isFlipped ? -1 : 1;
transferDataToPad( &m_padMaster );
transferDataToPad( m_padMaster );
// m_padMaster is a pattern: ensure there is no net for this pad:
m_padMaster->SetNetCode( NETINFO_LIST::UNCONNECTED );
if( m_currentPad ) // Set current Pad parameters
{
@ -768,12 +779,12 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
m_currentPad->ClearFlags( DO_NOT_DRAW );
// Update values
m_currentPad->SetShape( m_padMaster.GetShape() );
m_currentPad->SetAttribute( m_padMaster.GetAttribute() );
m_currentPad->SetShape( m_padMaster->GetShape() );
m_currentPad->SetAttribute( m_padMaster->GetAttribute() );
if( m_currentPad->GetPosition() != m_padMaster.GetPosition() )
if( m_currentPad->GetPosition() != m_padMaster->GetPosition() )
{
m_currentPad->SetPosition( m_padMaster.GetPosition() );
m_currentPad->SetPosition( m_padMaster->GetPosition() );
rastnestIsChanged = true;
}
@ -785,54 +796,62 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
m_currentPad->SetPos0( pt );
m_currentPad->SetOrientation( m_padMaster.GetOrientation() * isign + module->GetOrientation() );
m_currentPad->SetOrientation( m_padMaster->GetOrientation() * isign + module->GetOrientation() );
m_currentPad->SetSize( m_padMaster.GetSize() );
m_currentPad->SetSize( m_padMaster->GetSize() );
size = m_padMaster.GetDelta();
size = m_padMaster->GetDelta();
size.y *= isign;
m_currentPad->SetDelta( size );
m_currentPad->SetDrillSize( m_padMaster.GetDrillSize() );
m_currentPad->SetDrillShape( m_padMaster.GetDrillShape() );
m_currentPad->SetDrillSize( m_padMaster->GetDrillSize() );
m_currentPad->SetDrillShape( m_padMaster->GetDrillShape() );
wxPoint offset = m_padMaster.GetOffset();
wxPoint offset = m_padMaster->GetOffset();
offset.y *= isign;
m_currentPad->SetOffset( offset );
m_currentPad->SetPadToDieLength( m_padMaster.GetPadToDieLength() );
m_currentPad->SetPadToDieLength( m_padMaster->GetPadToDieLength() );
if( m_currentPad->GetLayerMask() != m_padMaster.GetLayerMask() )
if( m_currentPad->GetLayerMask() != m_padMaster->GetLayerMask() )
{
rastnestIsChanged = true;
m_currentPad->SetLayerMask( m_padMaster.GetLayerMask() );
m_currentPad->SetLayerMask( m_padMaster->GetLayerMask() );
}
if( m_isFlipped )
m_currentPad->SetLayerMask( FlipLayerMask( m_currentPad->GetLayerMask() ) );
m_currentPad->SetPadName( m_padMaster.GetPadName() );
m_currentPad->SetPadName( m_padMaster->GetPadName() );
if( m_currentPad->GetNetname() != m_PadNetNameCtrl->GetValue() )
wxString padNetname;
// For PAD_HOLE_NOT_PLATED, ensure there is no net name selected
if( m_padMaster->GetAttribute() != PAD_HOLE_NOT_PLATED )
padNetname = m_PadNetNameCtrl->GetValue();
if( m_currentPad->GetNetname() != padNetname )
{
if( !m_PadNetNameCtrl->GetValue().IsEmpty() && m_padMaster.GetNetCode() == 0 )
const NETINFO_ITEM* netinfo = m_board->FindNet( padNetname );
if( !padNetname.IsEmpty() && netinfo == NULL )
{
DisplayError( NULL, _( "Unknown netname, netname not changed" ) );
}
else
{
rastnestIsChanged = true;
m_currentPad->SetNetCode( m_padMaster.GetNetCode() );
m_currentPad->SetNetCode( netinfo->GetNet() );
}
}
m_currentPad->SetLocalClearance( m_padMaster.GetLocalClearance() );
m_currentPad->SetLocalSolderMaskMargin( m_padMaster.GetLocalSolderMaskMargin() );
m_currentPad->SetLocalSolderPasteMargin( m_padMaster.GetLocalSolderPasteMargin() );
m_currentPad->SetLocalSolderPasteMarginRatio( m_padMaster.GetLocalSolderPasteMarginRatio() );
m_currentPad->SetZoneConnection( m_padMaster.GetZoneConnection() );
m_currentPad->SetThermalWidth( m_padMaster.GetThermalWidth() );
m_currentPad->SetThermalGap( m_padMaster.GetThermalGap() );
m_currentPad->SetLocalClearance( m_padMaster->GetLocalClearance() );
m_currentPad->SetLocalSolderMaskMargin( m_padMaster->GetLocalSolderMaskMargin() );
m_currentPad->SetLocalSolderPasteMargin( m_padMaster->GetLocalSolderPasteMargin() );
m_currentPad->SetLocalSolderPasteMarginRatio( m_padMaster->GetLocalSolderPasteMarginRatio() );
m_currentPad->SetZoneConnection( m_padMaster->GetZoneConnection() );
m_currentPad->SetThermalWidth( m_padMaster->GetThermalWidth() );
m_currentPad->SetThermalGap( m_padMaster->GetThermalGap() );
module->CalculateBoundingBox();
m_parent->SetMsgPanel( m_currentPad );
@ -984,6 +1003,7 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad )
// Check if user has set an existing net name
const NETINFO_ITEM* netinfo = m_board->FindNet( m_PadNetNameCtrl->GetValue() );
if( netinfo != NULL )
aPad->SetNetCode( netinfo->GetNet() );
else

View File

@ -87,23 +87,28 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
aModule = newModule;
GetBoard()->Add( aModule );
GetBoard()->Add( newModule );
aModule->ClearFlags();
newModule->ClearFlags();
GetBoard()->BuildListOfNets();
// Clear references to net info, because the footprint editor
// does know any thing about nets handled by the current edited board.
// Morever the main board can change or the net info relative to this main board
// can change while editing this footprint in the footprint editor
for( D_PAD* pad = newModule->Pads(); pad; pad = pad->Next() )
pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
SetCrossHairPosition( wxPoint( 0, 0 ) );
PlaceModule( aModule, NULL );
PlaceModule( newModule, NULL );
// Put it on FRONT layer,
// because this is the default in ModEdit, and in libs
if( aModule->GetLayer() != LAYER_N_FRONT )
aModule->Flip( aModule->GetPosition() );
if( newModule->GetLayer() != LAYER_N_FRONT )
newModule->Flip( newModule->GetPosition() );
// Put it in orientation 0,
// because this is the default orientation in ModEdit, and in libs
Rotate_Module( NULL, aModule, 0, false );
Rotate_Module( NULL, newModule, 0, false );
GetScreen()->ClrModify();
Zoom_Automatique( false );

View File

@ -46,7 +46,6 @@
#include <class_module.h>
#include <pcbnew.h>
#include <protos.h>
#include <pcbnew_id.h>
#include <hotkeys.h>
#include <module_editor_frame.h>