DRAWSEGMENT fix crash when trying to copy a empty polygon.
SHAPE_POLY_SET: fix crash in VertexCount when it is a empty poly set, or when params are incorrect. minor other fixes: warning in degug mode in dialog_dxf_import_base.cpp pcb_painter.cpp: remove a useless debug line.
This commit is contained in:
parent
73c88bd0fe
commit
78ec983632
|
@ -220,7 +220,10 @@ void SHAPE_POLY_SET::InsertVertex( int aGlobalIndex, VECTOR2I aNewVertex )
|
||||||
|
|
||||||
int SHAPE_POLY_SET::VertexCount( int aOutline , int aHole ) const
|
int SHAPE_POLY_SET::VertexCount( int aOutline , int aHole ) const
|
||||||
{
|
{
|
||||||
if( aOutline < 0 )
|
if( m_polys.size() == 0 ) // Empty poly set
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if( aOutline < 0 ) // Use last outline
|
||||||
aOutline += m_polys.size();
|
aOutline += m_polys.size();
|
||||||
|
|
||||||
int idx;
|
int idx;
|
||||||
|
@ -230,8 +233,11 @@ int SHAPE_POLY_SET::VertexCount( int aOutline , int aHole ) const
|
||||||
else
|
else
|
||||||
idx = aHole + 1;
|
idx = aHole + 1;
|
||||||
|
|
||||||
assert ( aOutline < (int)m_polys.size() );
|
if( aOutline >= (int)m_polys.size() ) // not existing outline
|
||||||
assert ( idx < (int)m_polys[aOutline].size() );
|
return 0;
|
||||||
|
|
||||||
|
if( idx >= (int)m_polys[aOutline].size() ) // not existing hole
|
||||||
|
return 0;
|
||||||
|
|
||||||
return m_polys[aOutline][idx].PointCount();
|
return m_polys[aOutline][idx].PointCount();
|
||||||
}
|
}
|
||||||
|
|
|
@ -496,8 +496,11 @@ class SHAPE_POLY_SET : public SHAPE
|
||||||
///> Returns the number of holes in a given outline
|
///> Returns the number of holes in a given outline
|
||||||
int HoleCount( int aOutline ) const
|
int HoleCount( int aOutline ) const
|
||||||
{
|
{
|
||||||
if( (aOutline > (int)m_polys.size()) || (m_polys[aOutline].size() < 2) )
|
if( ( aOutline < 0 ) || (aOutline >= (int)m_polys.size()) || (m_polys[aOutline].size() < 2) )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
// the first polygon in m_polys[aOutline] is the main contour,
|
||||||
|
// only others are holes:
|
||||||
return m_polys[aOutline].size() - 1;
|
return m_polys[aOutline].size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1053,9 +1056,9 @@ class SHAPE_POLY_SET : public SHAPE
|
||||||
POLYGON chamferFilletPolygon( CORNER_MODE aMode, unsigned int aDistance,
|
POLYGON chamferFilletPolygon( CORNER_MODE aMode, unsigned int aDistance,
|
||||||
int aIndex, int aSegments = -1 );
|
int aIndex, int aSegments = -1 );
|
||||||
|
|
||||||
typedef std::vector<POLYGON> Polyset;
|
typedef std::vector<POLYGON> POLYSET;
|
||||||
|
|
||||||
Polyset m_polys;
|
POLYSET m_polys;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -409,6 +409,8 @@ const EDA_RECT DRAWSEGMENT::GetBoundingBox() const
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_POLYGON:
|
case S_POLYGON:
|
||||||
|
if( m_Poly.IsEmpty() )
|
||||||
|
break;
|
||||||
{
|
{
|
||||||
wxPoint p_end;
|
wxPoint p_end;
|
||||||
MODULE* module = GetParentModule();
|
MODULE* module = GetParentModule();
|
||||||
|
@ -442,6 +444,7 @@ const EDA_RECT DRAWSEGMENT::GetBoundingBox() const
|
||||||
p_end.y = std::max( p_end.y, pt.y );
|
p_end.y = std::max( p_end.y, pt.y );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bbox.SetEnd( p_end );
|
bbox.SetEnd( p_end );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -748,7 +751,7 @@ const std::vector<wxPoint> DRAWSEGMENT::GetPolyPoints() const
|
||||||
{
|
{
|
||||||
std::vector<wxPoint> rv;
|
std::vector<wxPoint> rv;
|
||||||
|
|
||||||
if( m_Poly.VertexCount() > 0 )
|
if( !m_Poly.IsEmpty() )
|
||||||
{
|
{
|
||||||
for ( auto iter = m_Poly.CIterate(); iter; iter++ )
|
for ( auto iter = m_Poly.CIterate(); iter; iter++ )
|
||||||
{
|
{
|
||||||
|
|
|
@ -199,6 +199,9 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_POLYGON:
|
case S_POLYGON:
|
||||||
|
if( m_Poly.IsEmpty() )
|
||||||
|
break;
|
||||||
|
|
||||||
{
|
{
|
||||||
// We must compute absolute coordinates from m_PolyPoints
|
// We must compute absolute coordinates from m_PolyPoints
|
||||||
// which are relative to module position, orientation 0
|
// which are relative to module position, orientation 0
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<property name="minimum_size"></property>
|
<property name="minimum_size"></property>
|
||||||
<property name="name">DIALOG_DXF_IMPORT_BASE</property>
|
<property name="name">DIALOG_DXF_IMPORT_BASE</property>
|
||||||
<property name="pos"></property>
|
<property name="pos"></property>
|
||||||
<property name="size">-1,-1</property>
|
<property name="size">455,297</property>
|
||||||
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
||||||
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
||||||
<property name="title">Import DXF File</property>
|
<property name="title">Import DXF File</property>
|
||||||
|
@ -1124,7 +1124,7 @@
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem" expanded="1">
|
<object class="sizeritem" expanded="1">
|
||||||
<property name="border">5</property>
|
<property name="border">5</property>
|
||||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND</property>
|
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
|
||||||
<property name="proportion">1</property>
|
<property name="proportion">1</property>
|
||||||
<object class="wxBitmapComboBox" expanded="1">
|
<object class="wxBitmapComboBox" expanded="1">
|
||||||
<property name="BottomDockable">1</property>
|
<property name="BottomDockable">1</property>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// C++ code generated with wxFormBuilder (version Jun 5 2014)
|
// C++ code generated with wxFormBuilder (version Aug 4 2017)
|
||||||
// http://www.wxformbuilder.org/
|
// http://www.wxformbuilder.org/
|
||||||
//
|
//
|
||||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||||
|
@ -56,7 +56,14 @@ DIALOG_DXF_IMPORT_BASE::DIALOG_DXF_IMPORT_BASE( wxWindow* parent, wxWindowID id,
|
||||||
bSizer6->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
bSizer6->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||||
|
|
||||||
m_DXFPCBXCoord = new wxTextCtrl( this, wxID_ANY, _("0.0"), wxDefaultPosition, wxDefaultSize, 0 );
|
m_DXFPCBXCoord = new wxTextCtrl( this, wxID_ANY, _("0.0"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
if ( !m_DXFPCBXCoord->HasFlag( wxTE_MULTILINE ) )
|
||||||
|
{
|
||||||
m_DXFPCBXCoord->SetMaxLength( 10 );
|
m_DXFPCBXCoord->SetMaxLength( 10 );
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
m_DXFPCBXCoord->SetMaxLength( 10 );
|
||||||
|
#endif
|
||||||
m_DXFPCBXCoord->SetToolTip( _("DXF origin on PCB Grid, X Coordinate") );
|
m_DXFPCBXCoord->SetToolTip( _("DXF origin on PCB Grid, X Coordinate") );
|
||||||
|
|
||||||
bSizer6->Add( m_DXFPCBXCoord, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
bSizer6->Add( m_DXFPCBXCoord, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||||
|
@ -72,7 +79,14 @@ DIALOG_DXF_IMPORT_BASE::DIALOG_DXF_IMPORT_BASE( wxWindow* parent, wxWindowID id,
|
||||||
bSizer7->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
bSizer7->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||||
|
|
||||||
m_DXFPCBYCoord = new wxTextCtrl( this, wxID_ANY, _("0.0"), wxDefaultPosition, wxDefaultSize, 0 );
|
m_DXFPCBYCoord = new wxTextCtrl( this, wxID_ANY, _("0.0"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
if ( !m_DXFPCBYCoord->HasFlag( wxTE_MULTILINE ) )
|
||||||
|
{
|
||||||
m_DXFPCBYCoord->SetMaxLength( 10 );
|
m_DXFPCBYCoord->SetMaxLength( 10 );
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
m_DXFPCBYCoord->SetMaxLength( 10 );
|
||||||
|
#endif
|
||||||
m_DXFPCBYCoord->SetToolTip( _("DXF origin on PCB Grid, Y Coordinate") );
|
m_DXFPCBYCoord->SetToolTip( _("DXF origin on PCB Grid, Y Coordinate") );
|
||||||
|
|
||||||
bSizer7->Add( m_DXFPCBYCoord, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
bSizer7->Add( m_DXFPCBYCoord, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||||
|
@ -112,7 +126,7 @@ DIALOG_DXF_IMPORT_BASE::DIALOG_DXF_IMPORT_BASE( wxWindow* parent, wxWindowID id,
|
||||||
bSizer8->Add( m_staticTextBrdlayer, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxTOP, 5 );
|
bSizer8->Add( m_staticTextBrdlayer, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxTOP, 5 );
|
||||||
|
|
||||||
m_SelLayerBox = new PCB_LAYER_BOX_SELECTOR( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
|
m_SelLayerBox = new PCB_LAYER_BOX_SELECTOR( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
|
||||||
bSizer8->Add( m_SelLayerBox, 1, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 );
|
bSizer8->Add( m_SelLayerBox, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||||
|
|
||||||
|
|
||||||
bSizerMain->Add( bSizer8, 0, wxALL|wxEXPAND, 5 );
|
bSizerMain->Add( bSizer8, 0, wxALL|wxEXPAND, 5 );
|
||||||
|
@ -132,7 +146,6 @@ DIALOG_DXF_IMPORT_BASE::DIALOG_DXF_IMPORT_BASE( wxWindow* parent, wxWindowID id,
|
||||||
|
|
||||||
this->SetSizer( bSizerMain );
|
this->SetSizer( bSizerMain );
|
||||||
this->Layout();
|
this->Layout();
|
||||||
bSizerMain->Fit( this );
|
|
||||||
|
|
||||||
this->Centre( wxBOTH );
|
this->Centre( wxBOTH );
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// C++ code generated with wxFormBuilder (version Jun 5 2014)
|
// C++ code generated with wxFormBuilder (version Aug 4 2017)
|
||||||
// http://www.wxformbuilder.org/
|
// http://www.wxformbuilder.org/
|
||||||
//
|
//
|
||||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||||
|
@ -69,7 +69,7 @@ class DIALOG_DXF_IMPORT_BASE : public DIALOG_SHIM
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DIALOG_DXF_IMPORT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Import DXF File"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
DIALOG_DXF_IMPORT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Import DXF File"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 455,297 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||||
~DIALOG_DXF_IMPORT_BASE();
|
~DIALOG_DXF_IMPORT_BASE();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -926,14 +926,11 @@ void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment, int aLayer )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_RECT:
|
case S_RECT:
|
||||||
wxASSERT_MSG( false, wxT( "Not tested yet" ) );
|
wxASSERT_MSG( false, "Not tested yet" );
|
||||||
m_gal->DrawRectangle( start, end );
|
m_gal->DrawRectangle( start, end );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_ARC:
|
case S_ARC:
|
||||||
printf( "S_ARC st %f end %f angle %f\n",
|
|
||||||
aSegment->GetArcAngleStart()/10.0, (aSegment->GetArcAngleStart() + aSegment->GetAngle())/10.0,
|
|
||||||
aSegment->GetAngle()/10.0 );
|
|
||||||
m_gal->DrawArcSegment( start, aSegment->GetRadius(),
|
m_gal->DrawArcSegment( start, aSegment->GetRadius(),
|
||||||
DECIDEG2RAD( aSegment->GetArcAngleStart() ),
|
DECIDEG2RAD( aSegment->GetArcAngleStart() ),
|
||||||
DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
|
DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
|
||||||
|
|
|
@ -838,6 +838,7 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
|
||||||
modSeg->SetBezControl2( seg->GetBezControl2() );
|
modSeg->SetBezControl2( seg->GetBezControl2() );
|
||||||
modSeg->SetBezierPoints( seg->GetBezierPoints() );
|
modSeg->SetBezierPoints( seg->GetBezierPoints() );
|
||||||
modSeg->SetPolyPoints( seg->GetPolyPoints() );
|
modSeg->SetPolyPoints( seg->GetPolyPoints() );
|
||||||
|
modSeg->SetLocalCoord();
|
||||||
converted = modSeg;
|
converted = modSeg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue