Commit 5d5a50dd authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: fix a bug which crashes Eeschema (when a label is being created, and...

Eeschema: fix a bug which crashes Eeschema (when a label is being created, and its type is changed  by popup menu, for instance to a text, before it was put on schematic)
remove unused file and minor coding style fix
parent 2bea1c67
......@@ -223,8 +223,18 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent )
m_canvas->CrossHairOff( &dc ); // Erase schematic cursor
text->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
screen->Remove( text );
screen->Append( newtext );
// For an exiting item (i.e. already in list):
// replace the existing item by the new text in list
for( SCH_ITEM* item = screen->GetDrawItems(); item != NULL; item = item->Next() )
{
if( item == text )
{
screen->Remove( text );
screen->Append( newtext );
break;
}
}
m_itemToRepeat = NULL;
OnModify();
newtext->Draw( m_canvas, &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
......@@ -246,7 +256,7 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent )
// So this is equivalent to delete text and add newtext
// If text if being currently edited (i.e. moved)
// we also save the initial copy of text, and prepare undo command for new text modifications.
// we must save it as modified text (if currently beeing edited), then deleted text,
// we must save it as modified text,if it is currently edited, then save as deleted text,
// and replace text with newtext
PICKED_ITEMS_LIST pickList;
ITEM_PICKER picker( text, UR_CHANGED );
......
......@@ -47,7 +47,7 @@ class CONNECTED_POINT
{
private:
BOARD_CONNECTED_ITEM * m_item; // a link to the parent item (track, via or pad)
wxPoint m_point; // the connection point (coordinate of this point)
wxPoint m_point; // coordinates of this connected point
public:
// ctor to build a CONNECTED_POINT instance, when the parent is a track or via
......
This diff is collapsed.
......@@ -98,7 +98,7 @@ void MIN_SPAN_TREE_PADS::AddTreeToRatsnest( std::vector<RATSNEST_ITEM> &aRatsnes
int MIN_SPAN_TREE_PADS::GetWeight( int aItem1, int aItem2 )
{
// NOTE: The distance (weight) between a node and itself should be 0
// so we add 1 to other distances th be sure we never have 0
// so we add 1 to other distances to be sure we never have 0
// in cases other than a node and itself
D_PAD* pad1 = (*m_PadsList)[aItem1];
......
......@@ -60,7 +60,7 @@ static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* Module,
void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen();
PCB_SCREEN* screen = (PCB_SCREEN*) GetScreen();
if( !GetBoard() || !screen )
return;
......@@ -71,18 +71,20 @@ void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
TraceWorkSheet( DC, screen, 0, IU_PER_MILS, wxEmptyString );
// Redraw the footprints
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
{
module->Draw( m_canvas, DC, GR_OR );
}
#ifdef USE_WX_OVERLAY
if( IsShown() )
{
m_overlay.Reset();
wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)DC );
wxDCOverlay overlaydc( m_overlay, (wxWindowDC*) DC );
overlaydc.Clear();
}
#endif
if( m_canvas->IsMouseCaptured() )
......@@ -109,17 +111,19 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness,
IU_PER_MILS, wxEmptyString );
GetBoard()->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST);
GetBoard()->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST );
DrawGeneralRatsnest( DC );
#ifdef USE_WX_OVERLAY
if( IsShown() )
{
m_overlay.Reset();
wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)DC );
wxDCOverlay overlaydc( m_overlay, (wxWindowDC*) DC );
overlaydc.Clear();
}
#endif
if( m_canvas->IsMouseCaptured() )
......@@ -148,18 +152,18 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const
* tracks. But a white track will cover any other color since it has
* more bits to OR in.
*/
for( TRACK* track = m_Track; track; track = track->Next() )
for( TRACK* track = m_Track; track; track = track->Next() )
{
track->Draw( aPanel, DC, aDrawMode );
}
for( SEGZONE* zone = m_Zone; zone; zone = zone->Next() )
for( SEGZONE* zone = m_Zone; zone; zone = zone->Next() )
{
zone->Draw( aPanel, DC, aDrawMode );
}
// Draw the graphic items
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
{
if( item->IsMoving() )
continue;
......@@ -173,7 +177,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const
item->Draw( aPanel, DC, aDrawMode );
break;
default:
default:
break;
}
}
......@@ -181,26 +185,26 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const
// Draw areas (i.e. zones)
for( int ii = 0; ii < GetAreaCount(); ii++ )
{
ZONE_CONTAINER* zone = GetArea(ii);
ZONE_CONTAINER* zone = GetArea( ii );
// Areas must be drawn here only if not moved or dragged,
// because these areas are drawn by ManageCursor() in a specific manner
if ( (zone->GetFlags() & (IN_EDIT | IS_DRAGGED | IS_MOVED)) == 0 )
if( ( zone->GetFlags() & (IN_EDIT | IS_DRAGGED | IS_MOVED) ) == 0 )
{
zone->Draw( aPanel, DC, aDrawMode );
zone->DrawFilledArea( aPanel, DC, aDrawMode );
}
}
for( MODULE* module = m_Modules; module; module = module->Next() )
for( MODULE* module = m_Modules; module; module = module->Next() )
{
bool display = true;
int layerMask = ALL_CU_LAYERS;
bool display = true;
int layerMask = ALL_CU_LAYERS;
if( module->IsMoving() )
continue;
if( !IsElementVisible( PCB_VISIBLE(MOD_FR_VISIBLE) ) )
if( !IsElementVisible( PCB_VISIBLE( MOD_FR_VISIBLE ) ) )
{
if( module->GetLayer() == LAYER_N_FRONT )
display = false;
......@@ -208,10 +212,11 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const
layerMask &= ~LAYER_FRONT;
}
if( !IsElementVisible( PCB_VISIBLE(MOD_BK_VISIBLE) ) )
if( !IsElementVisible( PCB_VISIBLE( MOD_BK_VISIBLE ) ) )
{
if( module->GetLayer() == LAYER_N_BACK )
display = false;
layerMask &= ~LAYER_BACK;
}
......@@ -225,7 +230,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const
DrawHighLight( aPanel, DC, GetHighLightNetCode() );
// draw the BOARD's markers last, otherwise the high light will erase any marker on a pad
for( unsigned i=0; i < m_markers.size(); ++i )
for( unsigned i = 0; i < m_markers.size(); ++i )
{
m_markers[i]->Draw( aPanel, DC, aDrawMode );
}
......@@ -244,7 +249,7 @@ void BOARD::DrawHighLight( EDA_DRAW_PANEL* am_canvas, wxDC* DC, int aNetCode )
// Redraw ZONE_CONTAINERS
BOARD::ZONE_CONTAINERS& zones = m_ZoneDescriptorList;
for( BOARD::ZONE_CONTAINERS::iterator zc = zones.begin(); zc!=zones.end(); ++zc )
for( BOARD::ZONE_CONTAINERS::iterator zc = zones.begin(); zc!=zones.end(); ++zc )
{
if( (*zc)->GetNet() == aNetCode )
{
......@@ -253,9 +258,9 @@ void BOARD::DrawHighLight( EDA_DRAW_PANEL* am_canvas, wxDC* DC, int aNetCode )
}
// Redraw any pads that have aNetCode
for( MODULE* module = m_Modules; module; module = module->Next() )
for( MODULE* module = m_Modules; module; module = module->Next() )
{
for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() )
for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() )
{
if( pad->GetNet() == aNetCode )
{
......@@ -265,7 +270,7 @@ void BOARD::DrawHighLight( EDA_DRAW_PANEL* am_canvas, wxDC* DC, int aNetCode )
}
// Redraw track and vias that have aNetCode
for( TRACK* seg = m_Track; seg; seg = seg->Next() )
for( TRACK* seg = m_Track; seg; seg = seg->Next() )
{
if( seg->GetNet() == aNetCode )
{
......@@ -285,12 +290,12 @@ static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* aModule,
{
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
int tmp = frame->m_DisplayPadFill;
int tmp = frame->m_DisplayPadFill;
frame->m_DisplayPadFill = false;
// Draw pads.
for( D_PAD* pad = aModule->m_Pads; pad; pad = pad->Next() )
for( D_PAD* pad = aModule->m_Pads; pad; pad = pad->Next() )
{
if( (pad->GetLayerMask() & aLayerMask) == 0 )
continue;
......
......@@ -560,6 +560,7 @@ void ZONE_CONTAINER::CopyPolygonsFromFilledPolysListToKiPolygonList( KI_POLYGON_
}
bpl::set_points( poly, cornerslist.begin(), cornerslist.end() );
aKiPolyList.push_back( poly );
}
}
......
......@@ -42,6 +42,7 @@
#include <polygon_test_point_inside.h>
static bool CmpZoneSubnetValue( const BOARD_CONNECTED_ITEM* a, const BOARD_CONNECTED_ITEM* b );
void Merge_SubNets_Connected_By_CopperAreas( BOARD* aPcb, int aNetcode );
// This helper function sort a list of zones by netcode,
......@@ -64,7 +65,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
{
// list of pads and tracks candidates on this layer and on this net.
// It is static to avoid multiple memory realloc.
static std::vector <BOARD_CONNECTED_ITEM*> Candidates;
static std::vector <BOARD_CONNECTED_ITEM*> candidates;
// clear .m_ZoneSubnet parameter for pads
for( MODULE* module = m_Modules; module; module = module->Next() )
......@@ -101,7 +102,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
// For a given net, examine the smaller zones first slightly speed up calculation
// (25% faster)
// this is only noticeable with very large boards and depends on board zones topology
// This is due to the fact some items are connected bt small zones ares,
// This is due to the fact some items are connected by small zones ares,
// before examining large zones areas and these items are not tested after a connection is found
sort(zones_candidates.begin(), zones_candidates.end(), sort_areas );
......@@ -123,12 +124,12 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
if( oldnetcode != netcode )
{
oldnetcode = netcode;
Candidates.clear();
candidates.clear();
// Build the list of pads candidates connected to the net:
Candidates.reserve( net->m_PadInNetList.size() );
candidates.reserve( net->m_PadInNetList.size() );
for( unsigned ii = 0; ii < net->m_PadInNetList.size(); ii++ )
Candidates.push_back( net->m_PadInNetList[ii] );
candidates.push_back( net->m_PadInNetList[ii] );
// Build the list of track candidates connected to the net:
TRACK* track = m_Track.GetFirst()->GetStartNetCode( netcode );
......@@ -136,7 +137,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
{
if( track->GetNet() != netcode )
break;
Candidates.push_back( track );
candidates.push_back( track );
}
}
......@@ -151,14 +152,14 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
subnet++;
EDA_RECT bbox = curr_zone->CalculateSubAreaBoundaryBox( indexstart, indexend );
for( unsigned ic = 0; ic < Candidates.size(); ic++ )
for( unsigned ic = 0; ic < candidates.size(); ic++ )
{ // test if this area is connected to a board item:
BOARD_CONNECTED_ITEM* item = Candidates[ic];
BOARD_CONNECTED_ITEM* item = candidates[ic];
if( item->GetZoneSubNet() == subnet ) // Already merged
continue;
if( !item->IsOnLayer( curr_zone->GetLayer() ) )
if( !item->IsOnLayer( curr_zone->GetLayer() ) )
continue;
wxPoint pos1, pos2;
......@@ -201,7 +202,8 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
}
if( connected )
{ // Set ZoneSubnet to the current subnet value.
{
// Set ZoneSubnet to the current subnet value.
// If the previous subnet is not 0, merge all items with old subnet
// to the new one
int old_subnet = item->GetZoneSubNet();
......@@ -210,12 +212,14 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
// Merge previous subnet with the current
if( (old_subnet > 0) && (old_subnet != subnet) )
{
for( unsigned jj = 0; jj < Candidates.size(); jj++ )
for( unsigned jj = 0; jj < candidates.size(); jj++ )
{
BOARD_CONNECTED_ITEM* item_to_merge = Candidates[jj];
BOARD_CONNECTED_ITEM* item_to_merge = candidates[jj];
if( old_subnet == item_to_merge->GetZoneSubNet() )
{
item_to_merge->SetZoneSubNet( subnet );
}
}
} // End if ( old_subnet > 0 )
} // End if( connected )
......
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