Commit 39497b10 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: fix Bug #1422093 (pcbnew crashes after editing a footprint cominng...

Pcbnew: fix  Bug #1422093 (pcbnew crashes after editing a footprint cominng from the board  with the fp editor and saving it on a librray and trying to load it to the board)
Some other very minor fixes.
parent dcdaee4c
......@@ -84,7 +84,6 @@ void S3D_MASTER::ObjectCoordsTo3DUnits( std::vector< S3D_VERTEX >& aVertices )
}
/* adjust offset position (offset is given in UNIT 3D (0.1 inch) */
#define SCALE_3D_CONV ((IU_PER_MILS * 1000) / UNITS3D_TO_UNITSPCB)
aVertices[ii].x += m_MatPosition.x * SCALE_3D_CONV;
aVertices[ii].y += m_MatPosition.y * SCALE_3D_CONV;
aVertices[ii].z += m_MatPosition.z * SCALE_3D_CONV;
......
......@@ -42,6 +42,14 @@
*/
#define UNITS3D_TO_UNITSPCB (IU_PER_MILS * 100)
/**
* scaling factor for 3D shape offset ( S3D_MASTER::m_MatPosition member )
* Was in inches in legacy version, and, due to a mistake, still in inches
* in .kicad_pcb files (which are using mm)
* so this scaling convert file units (inch) to 3D units (0.1 inch), only
* for S3D_MASTER::m_MatPosition parameter
*/
#define SCALE_3D_CONV 10
class S3D_MASTER;
class STRUCT_3D_SHAPE;
......
......@@ -75,9 +75,6 @@ void VRML1_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3
glm::vec3 matPos( GetMaster()->m_MatPosition.x, GetMaster()->m_MatPosition.y,
GetMaster()->m_MatPosition.z );
#define SCALE_3D_CONV ( (IU_PER_MILS * 1000.0f) / UNITS3D_TO_UNITSPCB )
// glPushMatrix();
glTranslatef( matPos.x * SCALE_3D_CONV, matPos.y * SCALE_3D_CONV, matPos.z * SCALE_3D_CONV );
......
......@@ -79,10 +79,6 @@ void X3D_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3Du
glm::vec3 matPos( GetMaster()->m_MatPosition.x, GetMaster()->m_MatPosition.y,
GetMaster()->m_MatPosition.z );
#define SCALE_3D_CONV ( (IU_PER_MILS * 1000.0f) / UNITS3D_TO_UNITSPCB )
glTranslatef( matPos.x * SCALE_3D_CONV, matPos.y * SCALE_3D_CONV, matPos.z * SCALE_3D_CONV );
glRotatef( -matRot.z, 0.0f, 0.0f, 1.0f );
......
......@@ -489,9 +489,7 @@ void HPGL_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre,
DPOINT pos_dev = userToDeviceCoordinates( pos );
int delta = KiROUND( penDiameter - penOverlap );
int radius = diametre / 2;
radius = ( diametre - KiROUND( penDiameter ) ) / 2;
int radius = ( diametre - KiROUND( penDiameter ) ) / 2;
if( radius < 0 )
radius = 0;
......
......@@ -489,7 +489,7 @@ void OPENGL_GAL::DrawPolygon( const std::deque<VECTOR2D>& aPointList )
boost::shared_array<GLdouble> points( new GLdouble[3 * aPointList.size()] );
int v = 0;
for( std::deque<VECTOR2D>::const_iterator it = aPointList.begin(); it != aPointList.end(); it++ )
for( std::deque<VECTOR2D>::const_iterator it = aPointList.begin(); it != aPointList.end(); ++it )
{
points[v] = it->x;
points[v + 1] = it->y;
......
......@@ -55,7 +55,7 @@ SHADER::~SHADER()
{
// Delete the shaders and the program
for( std::deque<GLuint>::iterator it = shaderNumbers.begin(); it != shaderNumbers.end();
it++ )
++it )
{
glDeleteShader( *it );
}
......
......@@ -231,13 +231,13 @@ int StrNumCmp( const wxString& aString1, const wxString& aString2, int aLength,
while( isdigit( *str1 ) )
{
nb1 = nb1 * 10 + (int) *str1 - '0';
str1++;
++str1;
}
while( isdigit( *str2 ) )
{
nb2 = nb2 * 10 + (int) *str2 - '0';
str2++;
++str2;
}
if( nb1 < nb2 )
......@@ -270,8 +270,8 @@ int StrNumCmp( const wxString& aString1, const wxString& aString2, int aLength,
return 0;
}
str1++;
str2++;
++str1;
++str2;
}
return 0;
......
......@@ -142,6 +142,8 @@ GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME* aFrame, const wxString
{
m_gerbview_frame = aFrame;
m_pcb_file_name = aFileName;
m_fp = NULL;
m_pcbCopperLayersCount = 2;
}
......
......@@ -358,7 +358,7 @@ void RECTWAVEGUIDE::show_results()
continue;
if( f >= ( fc( m, n ) ) )
{
sprintf( txt, "H(%u,%u) ", m, n );
sprintf( txt, "H(%d,%d) ", m, n );
if( (strlen( text ) + strlen( txt ) + 5) < MAXSTRLEN )
strcat( text, txt );
else
......@@ -384,7 +384,7 @@ void RECTWAVEGUIDE::show_results()
{
if( f >= fc( m, n ) )
{
sprintf( txt, "E(%u,%u) ", m, n );
sprintf( txt, "E(%d,%d) ", m, n );
if( (strlen( text ) + strlen( txt ) + 5) < MAXSTRLEN )
strcat( text, txt );
else
......
......@@ -2404,20 +2404,17 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
if( !net.IsValid() ) // Footprint pad had no net.
{
if( !pad->GetNetname().IsEmpty() )
if( aReporter && aReporter->ReportAll() )
{
if( aReporter && aReporter->ReportAll() )
{
msg.Printf( _( "Clearing component \"%s:%s\" pin \"%s\" net name.\n" ),
GetChars( footprint->GetReference() ),
GetChars( footprint->GetPath() ),
GetChars( pad->GetPadName() ) );
aReporter->Report( msg );
}
if( !aNetlist.IsDryRun() )
pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
msg.Printf( _( "Clearing component \"%s:%s\" pin \"%s\" net name.\n" ),
GetChars( footprint->GetReference() ),
GetChars( footprint->GetPath() ),
GetChars( pad->GetPadName() ) );
aReporter->Report( msg );
}
if( !aNetlist.IsDryRun() )
pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
}
else // Footprint pad has a net.
{
......
......@@ -50,7 +50,10 @@ BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( const BOARD_CONNECTED_ITEM& aItem )
void BOARD_CONNECTED_ITEM::SetNetCode( int aNetCode )
{
// assert( aNetCode >= 0 );
// if aNetCode < 0 ( typically NETINFO_LIST::FORCE_ORPHANED )
// or no parent board,
// set the m_netinfo to the dummy NETINFO_LIST::ORPHANED
BOARD* board = GetBoard();
if( ( aNetCode >= 0 ) && board )
......
......@@ -529,8 +529,11 @@ bool DRAWSEGMENT::HitTest( const wxPoint& aPosition ) const
return true;
break;
case S_POLYGON: // not yet handled
break;
default:
wxASSERT( 0 );
wxASSERT_MSG( 0, wxString::Format( "unknown DRAWSEGMENT shape: %d", m_Shape ) );
break;
}
......@@ -582,9 +585,15 @@ bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy
break;
case S_CURVE:
case S_POLYGON: // not yet handled
break;
default:
;
wxASSERT_MSG( 0, wxString::Format( "unknown DRAWSEGMENT shape: %d", m_Shape ) );
break;
}
return false;
}
......
......@@ -112,8 +112,6 @@ MODULE::MODULE( const MODULE& aModule ) :
m_Value->SetParent( this );
// Copy auxiliary data: Pads
// m_Pads.DeleteAll();
for( D_PAD* pad = aModule.m_Pads; pad; pad = pad->Next() )
{
D_PAD* newpad = new D_PAD( *pad );
......
......@@ -320,9 +320,14 @@ public:
return NULL;
}
///> Constant that holds the unconnected net number (typically 0)
///> Constant that holds the "unconnected net" number (typically 0)
///> all items "connected" to this net are actually not connected items
static const int UNCONNECTED;
///> Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED
///> (typically -1) when calling SetNetCode od board connected items
static const int FORCE_ORPHANED;
///> NETINFO_ITEM meaning that there was no net assigned for an item, as there was no
///> board storing net list available.
static NETINFO_ITEM ORPHANED;
......
......@@ -292,4 +292,6 @@ NETINFO_ITEM* NETINFO_MAPPING::iterator::operator->() const
const int NETINFO_LIST::UNCONNECTED = 0;
const int NETINFO_LIST::FORCE_ORPHANED = -1;
NETINFO_ITEM NETINFO_LIST::ORPHANED = NETINFO_ITEM( NULL, wxEmptyString, NETINFO_LIST::UNCONNECTED );
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="11" />
<FileVersion major="1" minor="13" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
......@@ -20,8 +20,10 @@
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
......@@ -236,7 +238,88 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticLine" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticline1</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxLI_HORIZONTAL</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property>
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -51,6 +51,9 @@ DIALOG_FOOTPRINT_WIZARD_LIST_BASE::DIALOG_FOOTPRINT_WIZARD_LIST_BASE( wxWindow*
bSizerMain->Add( m_footprintWizardsGrid, 1, wxALL|wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
......@@ -58,7 +61,7 @@ DIALOG_FOOTPRINT_WIZARD_LIST_BASE::DIALOG_FOOTPRINT_WIZARD_LIST_BASE( wxWindow*
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
bSizerMain->Add( m_sdbSizer, 0, wxEXPAND, 5 );
bSizerMain->Add( m_sdbSizer, 0, wxEXPAND|wxALL, 5 );
this->SetSizer( bSizerMain );
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -20,6 +20,7 @@ class DIALOG_SHIM;
#include <wx/font.h>
#include <wx/grid.h>
#include <wx/gdicmn.h>
#include <wx/statline.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
......@@ -36,6 +37,7 @@ class DIALOG_FOOTPRINT_WIZARD_LIST_BASE : public DIALOG_SHIM
protected:
wxGrid* m_footprintWizardsGrid;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
......
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="11" />
<FileVersion major="1" minor="13" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
......@@ -44,7 +44,7 @@
<property name="minimum_size"></property>
<property name="name">DIALOG_FP_PLUGIN_OPTIONS_BASE</property>
<property name="pos"></property>
<property name="size">-1,-1</property>
<property name="size">678,342</property>
<property name="style">wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title"></property>
......
......@@ -96,12 +96,13 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
newModule->ClearFlags();
// Clear references to net info, because the footprint editor
// Clear references to any 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
// Morever we do not want to save any reference to an unknown net when
// saving the footprint in lib cache
// so we force the ORPHANED dummy net info for all pads
for( D_PAD* pad = newModule->Pads(); pad; pad = pad->Next() )
pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
pad->SetNetCode( NETINFO_LIST::FORCE_ORPHANED );
SetCrossHairPosition( wxPoint( 0, 0 ) );
PlaceModule( newModule, NULL );
......@@ -269,6 +270,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
if( module )
{
GetBoard()->Add( module, ADD_APPEND );
lastComponentName = moduleName;
AddHistoryComponentName( HistoryList, moduleName );
......@@ -328,7 +330,14 @@ MODULE* PCB_BASE_FRAME::loadFootprint( const FPID& aFootprintId )
wxCHECK_MSG( fptbl, NULL, wxT( "Cannot look up FPID in NULL FP_LIB_TABLE." ) );
return fptbl->FootprintLoadWithOptionalNickname( aFootprintId );
MODULE* module = fptbl->FootprintLoadWithOptionalNickname( aFootprintId );
// Clear all references to any net info, to be sure there is no broken links
// to any netinfo list (This should be the case, but...)
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
pad->SetNetCode( NETINFO_LIST::FORCE_ORPHANED );
return module;
}
......
......@@ -426,14 +426,13 @@ void make_vcyl( bool inch, bool axial, double dia, double length,
void make_hcyl( bool inch, bool axial, double dia, double length,
double z, double wireDia )
{
bool ok = false;
stringstream tstr;
string line;
double pitch = 0.0;
double lead = 0.0; // lead length for radial leads
ok = false;
bool ok = false;
while( !ok )
{
if( axial )
......
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