Commit b1d1a711 authored by charras's avatar charras

Finished code cleaning about ratsnets calculations and handling.

Minor others changes.
parent 8f36c1fc
...@@ -78,7 +78,7 @@ Pcb3D_GLCanvas::~Pcb3D_GLCanvas() ...@@ -78,7 +78,7 @@ Pcb3D_GLCanvas::~Pcb3D_GLCanvas()
/*************************************/ /*************************************/
{ {
ClearLists(); ClearLists();
m_init = FALSE; m_init = FALSE;
} }
...@@ -224,7 +224,7 @@ void Pcb3D_GLCanvas::OnMouseEvent( wxMouseEvent& event ) ...@@ -224,7 +224,7 @@ void Pcb3D_GLCanvas::OnMouseEvent( wxMouseEvent& event )
/********************************************************/ /********************************************************/
{ {
wxSize size( GetClientSize() ); wxSize size( GetClientSize() );
double spin_quat[4]; double spin_quat[4];
if( event.RightDown() ) if( event.RightDown() )
...@@ -474,6 +474,7 @@ void Pcb3D_GLCanvas::OnPaint( wxPaintEvent& event ) ...@@ -474,6 +474,7 @@ void Pcb3D_GLCanvas::OnPaint( wxPaintEvent& event )
/*************************************************/ /*************************************************/
{ {
wxPaintDC dc( this ); wxPaintDC dc( this );
// Set the OpenGL viewport according to the client size of this canvas. // Set the OpenGL viewport according to the client size of this canvas.
// This is done here rather than in a wxSizeEvent handler because our // This is done here rather than in a wxSizeEvent handler because our
// OpenGL rendering context (and thus viewport setting) is used with // OpenGL rendering context (and thus viewport setting) is used with
...@@ -482,13 +483,12 @@ void Pcb3D_GLCanvas::OnPaint( wxPaintEvent& event ) ...@@ -482,13 +483,12 @@ void Pcb3D_GLCanvas::OnPaint( wxPaintEvent& event )
// is wrong when next another canvas is repainted. // is wrong when next another canvas is repainted.
const wxSize ClientSize = GetClientSize(); const wxSize ClientSize = GetClientSize();
glViewport(0, 0, ClientSize.x, ClientSize.y); glViewport( 0, 0, ClientSize.x, ClientSize.y );
Redraw(); Redraw();
event.Skip(); event.Skip();
} }
/***********************************************************/ /***********************************************************/
void Pcb3D_GLCanvas::OnEraseBackground( wxEraseEvent& event ) void Pcb3D_GLCanvas::OnEraseBackground( wxEraseEvent& event )
/***********************************************************/ /***********************************************************/
...@@ -518,7 +518,7 @@ void Pcb3D_GLCanvas::InitGL() ...@@ -518,7 +518,7 @@ void Pcb3D_GLCanvas::InitGL()
glMatrixMode( GL_PROJECTION ); glMatrixMode( GL_PROJECTION );
glLoadIdentity(); glLoadIdentity();
#define MAX_VIEW_ANGLE 160.0 / 45.0 #define MAX_VIEW_ANGLE 160.0 / 45.0
if( g_Parm_3D_Visu.m_Zoom > MAX_VIEW_ANGLE ) if( g_Parm_3D_Visu.m_Zoom > MAX_VIEW_ANGLE )
g_Parm_3D_Visu.m_Zoom = MAX_VIEW_ANGLE; g_Parm_3D_Visu.m_Zoom = MAX_VIEW_ANGLE;
gluPerspective( 45.0 * g_Parm_3D_Visu.m_Zoom, ratio_HV, 1, 10 ); gluPerspective( 45.0 * g_Parm_3D_Visu.m_Zoom, ratio_HV, 1, 10 );
...@@ -599,9 +599,9 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event ) ...@@ -599,9 +599,9 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
*/ */
{ {
wxFileName fn( m_Parent->m_Parent->GetScreen()->m_FileName ); wxFileName fn( m_Parent->m_Parent->GetScreen()->m_FileName );
wxString FullFileName; wxString FullFileName;
wxString file_ext, mask; wxString file_ext, mask;
bool fmt_is_jpeg = FALSE; bool fmt_is_jpeg = FALSE;
if( event.GetId() == ID_MENU_SCREENCOPY_JPEG ) if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
fmt_is_jpeg = TRUE; fmt_is_jpeg = TRUE;
...@@ -627,13 +627,26 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event ) ...@@ -627,13 +627,26 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
} }
Redraw( true ); Redraw( true );
wxSize image_size = GetClientSize();
wxClientDC dc( this ); struct vieport_params
wxBitmap bitmap( image_size.x, image_size.y ); {
wxMemoryDC memdc; GLint originx;
memdc.SelectObject( bitmap ); GLint originy;
memdc.Blit( 0, 0, image_size.x, image_size.y, &dc, 0, 0 ); GLint x;
memdc.SelectObject( wxNullBitmap ); GLint y;
} viewport;
glGetIntegerv( GL_VIEWPORT, (GLint*) &viewport );
unsigned char* pixelbuffer = (unsigned char*) malloc( 3 * viewport.x * viewport.y );
glReadPixels( 0, 0, viewport.x, viewport.y, GL_RGB, GL_UNSIGNED_BYTE, pixelbuffer );
wxImage image( viewport.x, viewport.y );
image.SetData( pixelbuffer );
image = image.Mirror();
image = image.Rotate90().Rotate90();
wxBitmap bitmap( image, -1 );
if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD ) if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
{ {
...@@ -650,8 +663,6 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event ) ...@@ -650,8 +663,6 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
} }
else else
{ {
wxImage image = bitmap.ConvertToImage();
if( !image.SaveFile( FullFileName, if( !image.SaveFile( FullFileName,
fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) ) fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
wxLogError( wxT( "Can't save file" ) ); wxLogError( wxT( "Can't save file" ) );
......
////////////////////////////////////// //////////////////////////////////////
// Name: 3d_draw.cpp // Name: 3d_draw.cpp
////////////////////////////////////// //////////////////////////////////////
#ifdef __GNUG__
#pragma implementation
#pragma interface
#endif
#include "fctsys.h" #include "fctsys.h"
#include "common.h"
#include "trigo.h" #include "trigo.h"
#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
#endif
#include "pcbstruct.h" #include "pcbstruct.h"
#include "macros.h" #include "macros.h"
#include "drawtxt.h" #include "drawtxt.h"
...@@ -27,6 +15,11 @@ ...@@ -27,6 +15,11 @@
#include "3d_struct.h" #include "3d_struct.h"
#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
#endif
static void Draw3D_FilledCircle( double posx, double posy, static void Draw3D_FilledCircle( double posx, double posy,
double rayon, double hole_rayon, double zpos ); double rayon, double hole_rayon, double zpos );
static void Draw3D_FilledSegment( double startx, double starty, static void Draw3D_FilledSegment( double startx, double starty,
...@@ -108,7 +101,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() ...@@ -108,7 +101,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List()
g_Parm_3D_Visu.m_BoardPos = pcb->m_BoundaryBox.Centre(); g_Parm_3D_Visu.m_BoardPos = pcb->m_BoundaryBox.Centre();
g_Parm_3D_Visu.m_BoardPos.y = -g_Parm_3D_Visu.m_BoardPos.y; g_Parm_3D_Visu.m_BoardPos.y = -g_Parm_3D_Visu.m_BoardPos.y;
g_Parm_3D_Visu.m_Layers = pcb->m_BoardSettings->m_CopperLayerCount; g_Parm_3D_Visu.m_Layers = pcb->m_BoardSettings->m_CopperLayerCount;
// Ensure the board has 2 sides for 3D views, because it is hard to find a *really* single side board in the true life... // Ensure the board has 2 sides for 3D views, because it is hard to find a *really* single side board in the true life...
if ( g_Parm_3D_Visu.m_Layers < 2 ) if ( g_Parm_3D_Visu.m_Layers < 2 )
g_Parm_3D_Visu.m_Layers = 2; g_Parm_3D_Visu.m_Layers = 2;
...@@ -489,7 +482,31 @@ void Pcb3D_GLCanvas::Draw3D_DrawText( TEXTE_PCB* text ) ...@@ -489,7 +482,31 @@ void Pcb3D_GLCanvas::Draw3D_DrawText( TEXTE_PCB* text )
s_Text3DZPos = g_Parm_3D_Visu.m_LayerZcoord[layer]; s_Text3DZPos = g_Parm_3D_Visu.m_LayerZcoord[layer];
s_Text3DWidth = text->m_Width * g_Parm_3D_Visu.m_BoardScale; s_Text3DWidth = text->m_Width * g_Parm_3D_Visu.m_BoardScale;
glNormal3f( 0.0, 0.0, Get3DLayerSide( layer ) ); glNormal3f( 0.0, 0.0, Get3DLayerSide( layer ) );
DrawGraphicText( NULL, NULL, text->m_Pos, (EDA_Colors) color, if( text->m_MultilineAllowed )
{
wxPoint pos = text->m_Pos;
wxArrayString* list = wxStringSplit( text->m_Text, '\n' );
wxPoint offset;
offset.y = text->GetInterline();
RotatePoint( &offset, text->m_Orient );
for( unsigned i = 0; i<list->Count(); i++ )
{
wxString txt = list->Item( i );
DrawGraphicText( NULL, NULL, pos, (EDA_Colors) color,
txt, text->m_Orient, text->m_Size,
text->m_HJustify, text->m_VJustify,
text->m_Width, text->m_Italic,
true,
Draw3dTextSegm );
pos += offset;
}
delete (list);
}
else
DrawGraphicText( NULL, NULL, text->m_Pos, (EDA_Colors) color,
text->m_Text, text->m_Orient, text->m_Size, text->m_Text, text->m_Orient, text->m_Size,
text->m_HJustify, text->m_VJustify, text->m_HJustify, text->m_VJustify,
text->m_Width, text->m_Italic, text->m_Width, text->m_Italic,
......
...@@ -31,7 +31,7 @@ void WinEDA3D_DrawFrame::ReCreateHToolbar() ...@@ -31,7 +31,7 @@ void WinEDA3D_DrawFrame::ReCreateHToolbar()
m_HToolBar->AddTool( ID_RELOAD3D_BOARD, wxEmptyString, m_HToolBar->AddTool( ID_RELOAD3D_BOARD, wxEmptyString,
wxBitmap( import3d_xpm ), wxBitmap( import3d_xpm ),
_( "Reload board" ) ); _( "Reload board" ) );
#ifdef __WINDOWS__ // do not work properly under linux #if (defined(__WINDOWS__) || defined(__APPLE__)) // do not work properly under linux
m_HToolBar-> AddSeparator(); m_HToolBar-> AddSeparator();
m_HToolBar->AddTool( ID_TOOL_SCREENCOPY_TOCLIBBOARD, wxEmptyString, m_HToolBar->AddTool( ID_TOOL_SCREENCOPY_TOCLIBBOARD, wxEmptyString,
......
...@@ -4,6 +4,14 @@ KiCad ChangeLog 2009 ...@@ -4,6 +4,14 @@ KiCad ChangeLog 2009
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2009-may-28 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
++Pcbnew:
Finished code cleaning about ratsnets calculations and handling
Obscure code removed ( I hope)
Better names for some members of BOARD class.
2009-may-24 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> 2009-may-24 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================ ================================================================================
++Pcbnew: ++Pcbnew:
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#define BUILD_VERSION wxT("(20090513-unstable)") #define BUILD_VERSION wxT("(20090525-unstable)")
wxString g_BuildVersion wxString g_BuildVersion
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* C4 CHIP_B * C4 CHIP_B
* D1 CHIP_B * D1 CHIP_B
* JP1 unknown * JP1 unknown
* *
*NET* *NET*
*SIGNAL* N03791 *SIGNAL* N03791
* C3.1 R1.1 JP2.7 U1.3 * C3.1 R1.1 JP2.7 U1.3
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
/* Generic netlist sample: /* Generic netlist sample:
* $BeginNetlist * $BeginNetlist
* $BeginComponentList * $BeginComponentList
* *
* $BeginComponent * $BeginComponent
* TimeStamp=32568D1E * TimeStamp=32568D1E
* Footprint= * Footprint=
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
* 16=REF5_1 * 16=REF5_1
* $EndPinList * $EndPinList
* $EndComponent * $EndComponent
* *
* $BeginComponent * $BeginComponent
* TimeStamp=325679C1 * TimeStamp=325679C1
* Footprint= * Footprint=
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
* $EndPinList * $EndPinList
* $EndComponent * $EndComponent
* $EndComponentList * $EndComponentList
* *
* $BeginNets * $BeginNets
* Net 0 "" * Net 0 ""
* Net 1 "GND" * Net 1 "GND"
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
* Net 173 "" * Net 173 ""
* BUS1 30 * BUS1 30
* $EndNets * $EndNets
* *
* $EndNetlist * $EndNetlist
*/ */
......
...@@ -60,8 +60,6 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query ) ...@@ -60,8 +60,6 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query )
GetBoard()->m_BoundaryBox.SetOrigin( 0, 0 ); GetBoard()->m_BoundaryBox.SetOrigin( 0, 0 );
GetBoard()->m_BoundaryBox.SetSize( 0, 0 ); GetBoard()->m_BoundaryBox.SetSize( 0, 0 );
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
GetBoard()->m_NbLoclinks = 0;
GetBoard()->m_NbLinks = 0;
GetBoard()->m_NbNodes = 0; GetBoard()->m_NbNodes = 0;
GetBoard()->m_NbNoconnect = 0; GetBoard()->m_NbNoconnect = 0;
......
...@@ -281,7 +281,7 @@ public: ...@@ -281,7 +281,7 @@ public:
void Compile_Ratsnest( wxDC* DC, bool affiche ); /* Recalcul complet du chevelu */ void Compile_Ratsnest( wxDC* DC, bool affiche ); /* Recalcul complet du chevelu */
void ReCompile_Ratsnest_After_Changes( wxDC* DC ); void ReCompile_Ratsnest_After_Changes( wxDC* DC );
int Test_1_Net_Ratsnest( wxDC* DC, int net_code ); int Test_1_Net_Ratsnest( wxDC* DC, int net_code );
char* build_ratsnest_module( wxDC* DC, MODULE* Module ); void build_ratsnest_module( wxDC* DC, MODULE* Module );
void trace_ratsnest_module( wxDC* DC ); void trace_ratsnest_module( wxDC* DC );
void Build_Board_Ratsnest( wxDC* DC ); void Build_Board_Ratsnest( wxDC* DC );
void DrawGeneralRatsnest( wxDC* DC, int net_code = 0 ); void DrawGeneralRatsnest( wxDC* DC, int net_code = 0 );
...@@ -521,7 +521,14 @@ public: ...@@ -521,7 +521,14 @@ public:
/* Fonctions specifiques */ /* Fonctions specifiques */
MODULE* ListAndSelectModuleName(); MODULE* ListAndSelectModuleName();
void Liste_Equipot( wxCommandEvent& event );
/** Function ListNetsAndSelect
* called by a command event
* displays the sorted list of nets in a dialog frame
* If a net is selected, it is hightlighted
*/
void ListNetsAndSelect( wxCommandEvent& event );
void Swap_Layers( wxCommandEvent& event ); void Swap_Layers( wxCommandEvent& event );
void Install_Test_DRC_Frame( wxDC* DC ); void Install_Test_DRC_Frame( wxDC* DC );
......
No preview for this file type
This diff is collapsed.
...@@ -69,7 +69,7 @@ int CalcDist( int, int, int ,int ); ...@@ -69,7 +69,7 @@ int CalcDist( int, int, int ,int );
/* BOARD.CPP */ /* BOARD.CPP */
bool ComputeMatriceSize(WinEDA_BasePcbFrame * frame, int pas_route); bool ComputeMatriceSize(WinEDA_BasePcbFrame * frame, int pas_route);
int Build_Work(BOARD * Pcb, RATSNEST_ITEM* pt_chevelus); int Build_Work(BOARD * Pcb);
void PlaceCells(BOARD * Pcb, int net_code, int flag = 0); void PlaceCells(BOARD * Pcb, int net_code, int flag = 0);
BoardCell GetCell( int, int, int ); BoardCell GetCell( int, int, int );
......
...@@ -61,10 +61,6 @@ static void TracePenaliteRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, i ...@@ -61,10 +61,6 @@ static void TracePenaliteRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, i
int marge, int Penalite, int masque_layer ); int marge, int Penalite, int masque_layer );
static MODULE* PickModule( WinEDA_PcbFrame* pcbframe, wxDC* DC ); static MODULE* PickModule( WinEDA_PcbFrame* pcbframe, wxDC* DC );
/* variables importees */
extern RATSNEST_ITEM* local_liste_chevelu; // adresse de base du buffer des chevelus locaux
extern int nb_local_chevelu; // nbr de links du module en deplacement
/********************************************************************************/ /********************************************************************************/
void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
...@@ -866,22 +862,18 @@ float WinEDA_PcbFrame::Compute_Ratsnest_PlaceModule( wxDC* DC ) ...@@ -866,22 +862,18 @@ float WinEDA_PcbFrame::Compute_Ratsnest_PlaceModule( wxDC* DC )
* penalite pour les inclinaisons se rapprochant de 45 degre * penalite pour les inclinaisons se rapprochant de 45 degre
*/ */
{ {
RATSNEST_ITEM* pt_local_chevelu; double cout, icout;
int ii;
float cout, icout;
int ox, oy; int ox, oy;
int fx, fy; int fx, fy;
int dx, dy; int dx, dy;
if( (GetBoard()->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK) == 0 ) if( (GetBoard()->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK) == 0 )
return -1; return -1;
pt_local_chevelu = local_liste_chevelu;
ii = nb_local_chevelu;
cout = 0; cout = 0;
while( ii-- > 0 ) for( unsigned ii = 0; ii < GetBoard()->m_LocalRatsnest.size(); ii++ )
{ {
RATSNEST_ITEM* pt_local_chevelu = &GetBoard()->m_LocalRatsnest[ii];
if( !(pt_local_chevelu->m_Status & LOCAL_RATSNEST_ITEM) ) if( !(pt_local_chevelu->m_Status & LOCAL_RATSNEST_ITEM) )
{ {
ox = pt_local_chevelu->m_PadStart->GetPosition().x - g_Offset_Module.x; ox = pt_local_chevelu->m_PadStart->GetPosition().x - g_Offset_Module.x;
...@@ -913,11 +905,9 @@ float WinEDA_PcbFrame::Compute_Ratsnest_PlaceModule( wxDC* DC ) ...@@ -913,11 +905,9 @@ float WinEDA_PcbFrame::Compute_Ratsnest_PlaceModule( wxDC* DC )
icout = sqrt( icout ); icout = sqrt( icout );
cout += icout; /* cout total = somme des couts de chaque chevelu */ cout += icout; /* cout total = somme des couts de chaque chevelu */
} }
pt_local_chevelu++;
} }
return cout; return (float)cout;
} }
...@@ -1102,8 +1092,7 @@ static MODULE* PickModule( WinEDA_PcbFrame* pcbframe, wxDC* DC ) ...@@ -1102,8 +1092,7 @@ static MODULE* PickModule( WinEDA_PcbFrame* pcbframe, wxDC* DC )
{ {
MODULE** BaseListeModules, ** pt_Dmod; MODULE** BaseListeModules, ** pt_Dmod;
MODULE* Module = NULL, * AltModule = NULL; MODULE* Module = NULL, * AltModule = NULL;
RATSNEST_ITEM* pt_local_chevelu; int NbModules;
int NbModules, ii;
BaseListeModules = GenListeModules( pcbframe->GetBoard(), &NbModules ); BaseListeModules = GenListeModules( pcbframe->GetBoard(), &NbModules );
if( BaseListeModules == NULL ) if( BaseListeModules == NULL )
...@@ -1127,13 +1116,10 @@ static MODULE* PickModule( WinEDA_PcbFrame* pcbframe, wxDC* DC ) ...@@ -1127,13 +1116,10 @@ static MODULE* PickModule( WinEDA_PcbFrame* pcbframe, wxDC* DC )
pcbframe->build_ratsnest_module( DC, *pt_Dmod ); pcbframe->build_ratsnest_module( DC, *pt_Dmod );
/* calcul du nombre de chevelus externes */ /* calcul du nombre de chevelus externes */
pt_local_chevelu = local_liste_chevelu; for( unsigned ii = 0; ii < pcbframe->GetBoard()->m_LocalRatsnest.size(); ii++ )
ii = nb_local_chevelu;
while( ii-- > 0 )
{ {
if( (pt_local_chevelu->m_Status & LOCAL_RATSNEST_ITEM) == 0 ) if( (pcbframe->GetBoard()->m_LocalRatsnest[ii].m_Status & LOCAL_RATSNEST_ITEM) == 0 )
(*pt_Dmod)->flag++; (*pt_Dmod)->flag++;
pt_local_chevelu++;
} }
} }
......
...@@ -33,8 +33,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode ) ...@@ -33,8 +33,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
/********************************************************/ /********************************************************/
/* init board, route traces*/ /* init board, route traces*/
{ {
int ii, start, stop; int start, stop;
RATSNEST_ITEM* ptmp;
MODULE* Module = NULL; MODULE* Module = NULL;
D_PAD* Pad = NULL; D_PAD* Pad = NULL;
int autoroute_net_code = -1; int autoroute_net_code = -1;
...@@ -94,9 +93,9 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode ) ...@@ -94,9 +93,9 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
Compile_Ratsnest( DC, TRUE ); Compile_Ratsnest( DC, TRUE );
/* Placement du flag CH_ROUTE_REQ sur les chevelus demandes */ /* Placement du flag CH_ROUTE_REQ sur les chevelus demandes */
ptmp = (RATSNEST_ITEM*) GetBoard()->m_Ratsnest; for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ )
for( ii = GetBoard()->GetNumRatsnests(); ii > 0; ii--, ptmp++ )
{ {
RATSNEST_ITEM* ptmp = &GetBoard()->m_FullRatsnest[ii];
ptmp->m_Status &= ~CH_ROUTE_REQ; ptmp->m_Status &= ~CH_ROUTE_REQ;
switch( mode ) switch( mode )
...@@ -130,8 +129,6 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode ) ...@@ -130,8 +129,6 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
} }
} }
ptmp = (RATSNEST_ITEM*) GetBoard()->m_Ratsnest;
start = time( NULL ); start = time( NULL );
/* Calcul du pas de routage fixe a 5 mils et plus */ /* Calcul du pas de routage fixe a 5 mils et plus */
...@@ -162,7 +159,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode ) ...@@ -162,7 +159,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
PlaceCells( GetBoard(), -1, FORCE_PADS ); PlaceCells( GetBoard(), -1, FORCE_PADS );
/* Construction de la liste des pistes a router */ /* Construction de la liste des pistes a router */
Build_Work( GetBoard(), ptmp ); Build_Work( GetBoard() );
// DisplayBoard(DrawPanel, DC); // DisplayBoard(DrawPanel, DC);
...@@ -190,19 +187,12 @@ void WinEDA_PcbFrame::Reset_Noroutable( wxDC* DC ) ...@@ -190,19 +187,12 @@ void WinEDA_PcbFrame::Reset_Noroutable( wxDC* DC )
* Si ce flag est a 1 il n'est pas reroute * Si ce flag est a 1 il n'est pas reroute
*/ */
{ {
int ii;
RATSNEST_ITEM* pt_rats;
if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK )== 0 ) if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK )== 0 )
Compile_Ratsnest( DC, TRUE ); Compile_Ratsnest( DC, TRUE );
pt_rats = (RATSNEST_ITEM*) GetBoard()->m_Ratsnest; for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ )
if( pt_rats == NULL )
return;
for( ii = GetBoard()->GetNumRatsnests(); ii > 0; ii--, pt_rats++ )
{ {
pt_rats->m_Status &= ~CH_UNROUTABLE; GetBoard()->m_FullRatsnest[ii].m_Status &= ~CH_UNROUTABLE;
} }
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
/* routines externes : */ /* routines externes : */
/* Routines definies ici: */ /* Routines definies ici: */
int Build_Work( BOARD* Pcb, RATSNEST_ITEM* pt_base_chevelu ); int Build_Work( BOARD* Pcb );
void PlaceCells( BOARD* Pcb, int net_code, int flag ); void PlaceCells( BOARD* Pcb, int net_code, int flag );
int InitBoard(); int InitBoard();
BoardCell GetCell( int, int, int ); BoardCell GetCell( int, int, int );
...@@ -336,12 +336,11 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag ) ...@@ -336,12 +336,11 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
/******************************************************/ /******************************************************/
int Build_Work( BOARD* Pcb, RATSNEST_ITEM* pt_base_chevelu ) int Build_Work( BOARD* Pcb )
/*****************************************************/ /*****************************************************/
/* Build liste conn */ /* Build liste conn */
{ {
int ii; RATSNEST_ITEM* pt_rats;
RATSNEST_ITEM* pt_rats = pt_base_chevelu;
D_PAD* pt_pad; D_PAD* pt_pad;
int r1, r2, c1, c2, current_net_code; int r1, r2, c1, c2, current_net_code;
RATSNEST_ITEM* pt_ch; RATSNEST_ITEM* pt_ch;
...@@ -350,8 +349,9 @@ int Build_Work( BOARD* Pcb, RATSNEST_ITEM* pt_base_chevelu ) ...@@ -350,8 +349,9 @@ int Build_Work( BOARD* Pcb, RATSNEST_ITEM* pt_base_chevelu )
InitWork(); /* clear work list */ InitWork(); /* clear work list */
Ntotal = 0; Ntotal = 0;
for( ii = Pcb->GetNumRatsnests(); ii > 0; ii--, pt_rats++ ) for( unsigned ii = 0;Pcb->GetRatsnestsCount(); ii++ )
{ {
pt_rats = &Pcb->m_FullRatsnest[ii];
/* On ne route que les chevelus actifs et routables */ /* On ne route que les chevelus actifs et routables */
if( (pt_rats->m_Status & CH_ACTIF) == 0 ) if( (pt_rats->m_Status & CH_ACTIF) == 0 )
continue; continue;
......
This diff is collapsed.
...@@ -82,12 +82,9 @@ private: ...@@ -82,12 +82,9 @@ private:
public: public:
WinEDA_BasePcbFrame* m_PcbFrame; // Window de visualisation WinEDA_BasePcbFrame* m_PcbFrame; // Window de visualisation
EDA_Rect m_BoundaryBox; // Board size and position EDA_Rect m_BoundaryBox; // Board size and position
int m_Unused;
int m_Status_Pcb; // Flags used in ratsnet calculation and update int m_Status_Pcb; // Flags used in ratsnet calculation and update
EDA_BoardDesignSettings* m_BoardSettings; // Link to current design settings EDA_BoardDesignSettings* m_BoardSettings; // Link to current design settings
int m_NbNodes; // Active pads (pads attached to a net ) count int m_NbNodes; // Active pads (pads attached to a net ) count
int m_NbLinks; // Ratsnest count
int m_NbLoclinks; // Number of ratsnests from mouse cursor to pads to show while creating a track
int m_NbNoconnect; // Active ratsnet count (rastnests not alraedy connected by tracks) int m_NbNoconnect; // Active ratsnet count (rastnests not alraedy connected by tracks)
DLIST<BOARD_ITEM> m_Drawings; // linked list of lines & texts DLIST<BOARD_ITEM> m_Drawings; // linked list of lines & texts
...@@ -98,8 +95,9 @@ public: ...@@ -98,8 +95,9 @@ public:
std::vector<D_PAD*> m_Pads; // Entry for a sorted pad list (used in ratsnest calculations) std::vector<D_PAD*> m_Pads; // Entry for a sorted pad list (used in ratsnest calculations)
NETINFO_LIST* m_NetInfo; // nets info list (name, design constraints .. NETINFO_LIST* m_NetInfo; // nets info list (name, design constraints ..
RATSNEST_ITEM* m_Ratsnest; // Rastnest list std::vector<RATSNEST_ITEM> m_FullRatsnest; // Rastnest list for the BOARD
RATSNEST_ITEM* m_LocalRatsnest; // Rastnest list used while moving a footprint std::vector<RATSNEST_ITEM> m_LocalRatsnest; /* Rastnest list relative to a given footprint
(used while moving a footprint) */
ZONE_CONTAINER* m_CurrentZoneContour; // zone contour currently in progress ZONE_CONTAINER* m_CurrentZoneContour; // zone contour currently in progress
...@@ -233,27 +231,26 @@ public: ...@@ -233,27 +231,26 @@ public:
/* Routines de calcul des nombres de segments pistes et zones */ /* Routines de calcul des nombres de segments pistes et zones */
int GetNumSegmTrack(); int GetNumSegmTrack();
int GetNumSegmZone(); int GetNumSegmZone();
int GetNumNoconnect(); // retourne le nombre de connexions manquantes unsigned GetNoconnectCount(); // retourne le nombre de connexions manquantes
/** /**
* Function GetNumRatsnests * Function GetNumRatsnests
* @return int - The number of rats * @return int - The number of rats
*/ */
int GetNumRatsnests() unsigned GetRatsnestsCount()
{ {
return m_NbLinks; return m_FullRatsnest.size();
} }
int GetNumNodes(); // retourne le nombre de pads a netcode > 0 unsigned GetNodesCount(); // retourne le nombre de pads a netcode > 0
/** Function Build_Pads_Full_List /** Function Build_Pads_Full_List
* Create the pad list * Create the pad list
* initialise: * initialise:
* m_Pads (list of pads) * m_Pads (list of pads)
* m_NbNodes = 0
* set m_Status_Pcb = LISTE_PAD_OK; * set m_Status_Pcb = LISTE_PAD_OK;
* and clear for all pads the m_SubRatsnest member; * and clear for all pads in list the m_SubRatsnest member;
* delete ( free memory) m_Pcb->m_Ratsnest and set m_Pcb->m_Ratsnest to NULL * clear m_Pcb->m_FullRatsnest
*/ */
void Build_Pads_Full_List(); void Build_Pads_Full_List();
......
...@@ -81,10 +81,10 @@ public: ...@@ -81,10 +81,10 @@ public:
*/ */
void Append( NETINFO_ITEM* aNewElement ); void Append( NETINFO_ITEM* aNewElement );
/** Function Clear /** Function DeleteData
* delete the list of nets (and free memory) * delete the list of nets (and free memory)
*/ */
void Clear(); void DeleteData();
/** Function BuildListOfNets /** Function BuildListOfNets
* initialize the list of NETINFO_ITEM m_NetBuffer * initialize the list of NETINFO_ITEM m_NetBuffer
...@@ -112,9 +112,8 @@ public: ...@@ -112,9 +112,8 @@ public:
int m_NbNoconn; // Ratsnets remaining to route count int m_NbNoconn; // Ratsnets remaining to route count
int m_ForceWidth; // specific width (O = default width) int m_ForceWidth; // specific width (O = default width)
std::vector <D_PAD*> m_ListPad; // List of pads connected to this net std::vector <D_PAD*> m_ListPad; // List of pads connected to this net
RATSNEST_ITEM* m_RatsnestStart; // pointeur sur debut de liste ratsnests du net unsigned m_RatsnestStart; // debut de liste ratsnests du net (included)
RATSNEST_ITEM* m_RatsnestEnd; // pointeur sur fin de liste ratsnests du net unsigned m_RatsnestEnd; // fin de liste ratsnests du net (excluded)
std::vector <RATSNEST_ITEM*> m_ListRatsnest; // List of Ratsnests for this net
NETINFO_ITEM( BOARD_ITEM* aParent ); NETINFO_ITEM( BOARD_ITEM* aParent );
~NETINFO_ITEM(); ~NETINFO_ITEM();
......
...@@ -19,8 +19,8 @@ NETINFO_ITEM::NETINFO_ITEM( BOARD_ITEM* aParent ) ...@@ -19,8 +19,8 @@ NETINFO_ITEM::NETINFO_ITEM( BOARD_ITEM* aParent )
SetNet( 0 ); SetNet( 0 );
m_NbNodes = m_NbLink = m_NbNoconn = 0; m_NbNodes = m_NbLink = m_NbNoconn = 0;
m_ForceWidth = 0; m_ForceWidth = 0;
m_RatsnestStart = NULL; // pointeur sur debut de liste ratsnests du net m_RatsnestStart = 0; // debut de liste ratsnests du net
m_RatsnestEnd = NULL; // pointeur sur fin de liste ratsnests du net m_RatsnestEnd = 0; // fin de liste ratsnests du net
} }
......
...@@ -19,7 +19,7 @@ NETINFO_LIST::NETINFO_LIST( BOARD* aParent ) ...@@ -19,7 +19,7 @@ NETINFO_LIST::NETINFO_LIST( BOARD* aParent )
NETINFO_LIST::~NETINFO_LIST() NETINFO_LIST::~NETINFO_LIST()
{ {
Clear(); DeleteData();
} }
...@@ -35,10 +35,10 @@ NETINFO_ITEM* NETINFO_LIST::GetItem( int aNetcode ) ...@@ -35,10 +35,10 @@ NETINFO_ITEM* NETINFO_LIST::GetItem( int aNetcode )
} }
/** Function Clear /** Function DeleteData
* delete the list of nets (and free memory) * delete the list of nets (and free memory)
*/ */
void NETINFO_LIST::Clear() void NETINFO_LIST::DeleteData()
{ {
for( unsigned ii = 0; ii < GetCount(); ii++ ) for( unsigned ii = 0; ii < GetCount(); ii++ )
delete m_NetBuffer[ii]; delete m_NetBuffer[ii];
...@@ -83,7 +83,7 @@ void NETINFO_LIST::BuildListOfNets() ...@@ -83,7 +83,7 @@ void NETINFO_LIST::BuildListOfNets()
int nodes_count = 0; int nodes_count = 0;
NETINFO_ITEM* net_item; NETINFO_ITEM* net_item;
Clear(); // Remove all nets info and free memory DeleteData(); // Remove all nets info and free memory
// Create and add the "unconnected net" // Create and add the "unconnected net"
net_item = new NETINFO_ITEM( m_Parent ); net_item = new NETINFO_ITEM( m_Parent );
...@@ -135,13 +135,12 @@ void BOARD::Build_Pads_Full_List() ...@@ -135,13 +135,12 @@ void BOARD::Build_Pads_Full_List()
/**********************************/ /**********************************/
/** Function Build_Pads_Full_List /** Function Build_Pads_Full_List
* Create the pad list * Create the pad list, sorted by net names
* initialise: * initialise:
* m_Pads (list of pads) * m_Pads (list of pads)
* m_NbNodes = 0
* set m_Status_Pcb = LISTE_PAD_OK; * set m_Status_Pcb = LISTE_PAD_OK;
* and clear for all pads the m_SubRatsnest member; * also clear m_Pcb->m_FullRatsnest that could have bad data
* delete ( free memory) m_Pcb->m_Ratsnest and set m_Pcb->m_Ratsnest to NULL * (m_Pcb->m_FullRatsnest uses pointer to pads)
*/ */
{ {
if( m_Status_Pcb & LISTE_PAD_OK ) if( m_Status_Pcb & LISTE_PAD_OK )
...@@ -149,8 +148,7 @@ void BOARD::Build_Pads_Full_List() ...@@ -149,8 +148,7 @@ void BOARD::Build_Pads_Full_List()
// empty the old list // empty the old list
m_Pads.clear(); m_Pads.clear();
m_FullRatsnest.clear();
m_NbNodes = 0;
/* Clear variables used in rastnest computation */ /* Clear variables used in rastnest computation */
for( MODULE* module = m_Modules; module; module = module->Next() ) for( MODULE* module = m_Modules; module; module = module->Next() )
...@@ -161,20 +159,11 @@ void BOARD::Build_Pads_Full_List() ...@@ -161,20 +159,11 @@ void BOARD::Build_Pads_Full_List()
pad->SetSubRatsnest( 0 ); pad->SetSubRatsnest( 0 );
pad->SetParent( module ); pad->SetParent( module );
if( pad->GetNet() )
m_NbNodes++;
} }
} }
// Sort pad list per net // Sort pad list per net
sort( m_Pads.begin(), m_Pads.end(), PadlistSortByNetnames ); sort( m_Pads.begin(), m_Pads.end(), PadlistSortByNetnames );
if( m_Ratsnest )
{
MyFree( m_Ratsnest );
m_Ratsnest = NULL;
}
m_Status_Pcb = LISTE_PAD_OK; m_Status_Pcb = LISTE_PAD_OK;
} }
...@@ -886,10 +886,10 @@ void TRACK::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -886,10 +886,10 @@ void TRACK::DisplayInfo( WinEDA_DrawFrame* frame )
{ {
/* Display NetName pour les segments de piste type cuivre */ /* Display NetName pour les segments de piste type cuivre */
NETINFO_ITEM* equipot = board->FindNet( GetNet() ); NETINFO_ITEM* net = board->FindNet( GetNet() );
if( equipot ) if( net )
msg = equipot->GetNetname(); msg = net->GetNetname();
else else
msg = wxT( "<noname>" ); msg = wxT( "<noname>" );
......
...@@ -363,7 +363,7 @@ void WinEDA_BasePcbFrame::test_1_net_connexion( wxDC* DC, int net_code ) ...@@ -363,7 +363,7 @@ void WinEDA_BasePcbFrame::test_1_net_connexion( wxDC* DC, int net_code )
/* Display results */ /* Display results */
msg.Printf( wxT( "links %d nc %d net:nc %d" ), msg.Printf( wxT( "links %d nc %d net:nc %d" ),
m_Pcb->m_NbLinks, m_Pcb->GetNumNoconnect(), m_Pcb->GetRatsnestsCount(), m_Pcb->GetNoconnectCount(),
nb_net_noconnect ); nb_net_noconnect );
Affiche_Message( msg ); Affiche_Message( msg );
......
...@@ -302,12 +302,12 @@ void DRC::testUnconnected() ...@@ -302,12 +302,12 @@ void DRC::testUnconnected()
m_mainWindow->Compile_Ratsnest( &dc, TRUE ); m_mainWindow->Compile_Ratsnest( &dc, TRUE );
} }
if( m_pcb->m_Ratsnest == NULL ) if( m_pcb->GetRatsnestsCount() == 0 )
return; return;
RATSNEST_ITEM* rat = m_pcb->m_Ratsnest; for( unsigned ii = 0; ii < m_pcb->GetRatsnestsCount(); ++ii )
for( int i = 0; i<m_pcb->GetNumRatsnests(); ++i, ++rat )
{ {
RATSNEST_ITEM* rat = &m_pcb->m_FullRatsnest[ii];
if( (rat->m_Status & CH_ACTIF) == 0 ) if( (rat->m_Status & CH_ACTIF) == 0 )
continue; continue;
......
...@@ -43,8 +43,7 @@ void WinEDA_PcbFrame::Ratsnest_On_Off( wxDC* DC ) ...@@ -43,8 +43,7 @@ void WinEDA_PcbFrame::Ratsnest_On_Off( wxDC* DC )
/* Affiche ou efface le chevelu selon l'etat du bouton d'appel */ /* Affiche ou efface le chevelu selon l'etat du bouton d'appel */
{ {
int ii; unsigned ii;
RATSNEST_ITEM* pt_chevelu;
if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 ) if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
{ {
...@@ -55,24 +54,23 @@ void WinEDA_PcbFrame::Ratsnest_On_Off( wxDC* DC ) ...@@ -55,24 +54,23 @@ void WinEDA_PcbFrame::Ratsnest_On_Off( wxDC* DC )
DrawGeneralRatsnest( DC, 0 ); /* effacement eventuel du chevelu affiche */ DrawGeneralRatsnest( DC, 0 ); /* effacement eventuel du chevelu affiche */
pt_chevelu = GetBoard()->m_Ratsnest; if( GetBoard()->GetRatsnestsCount() == 0 )
if( pt_chevelu == NULL )
return; return;
if( g_Show_Ratsnest ) if( g_Show_Ratsnest )
{ {
for( ii = GetBoard()->GetNumRatsnests(); ii > 0; pt_chevelu++, ii-- ) for( ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ )
{ {
pt_chevelu->m_Status |= CH_VISIBLE; GetBoard()->m_FullRatsnest[ii].m_Status |= CH_VISIBLE;
} }
DrawGeneralRatsnest( DC, 0 ); DrawGeneralRatsnest( DC, 0 );
} }
else else
{ {
for( ii = GetBoard()->GetNumRatsnests(); ii > 0; pt_chevelu++, ii-- ) for( ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ )
{ {
pt_chevelu->m_Status &= ~CH_VISIBLE; GetBoard()->m_FullRatsnest[ii].m_Status &= ~CH_VISIBLE;
} }
} }
} }
...@@ -344,18 +342,14 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) ...@@ -344,18 +342,14 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
* Efface le chevelu affiche si aucun module ou pad n'est selectionne * Efface le chevelu affiche si aucun module ou pad n'est selectionne
*/ */
{ {
int ii;
RATSNEST_ITEM* pt_chevelu;
D_PAD* pt_pad = NULL; D_PAD* pt_pad = NULL;
MODULE* Module = NULL; MODULE* Module = NULL;
if( g_Show_Ratsnest ) if( g_Show_Ratsnest )
return; // Deja Affich� return;
if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 ) if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
{
Compile_Ratsnest( DC, TRUE ); Compile_Ratsnest( DC, TRUE );
}
if( item ) if( item )
{ {
...@@ -368,24 +362,18 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) ...@@ -368,24 +362,18 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
if( pt_pad ) /* Affichage du chevelu du net correspondant */ if( pt_pad ) /* Affichage du chevelu du net correspondant */
{ {
pt_pad->DisplayInfo( this ); pt_pad->DisplayInfo( this );
pt_chevelu = (RATSNEST_ITEM*) GetBoard()->m_Ratsnest; for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ )
for( ii = GetBoard()->GetNumRatsnests(); ii > 0; pt_chevelu++, ii-- )
{ {
if( pt_chevelu->GetNet() == pt_pad->GetNet() ) RATSNEST_ITEM* net = &GetBoard()->m_FullRatsnest[ii];
if( net->GetNet() == pt_pad->GetNet() )
{ {
if( (pt_chevelu->m_Status & CH_VISIBLE) != 0 ) if( (net->m_Status & CH_VISIBLE) != 0 )
continue; continue;
pt_chevelu->m_Status |= CH_VISIBLE; net->m_Status |= CH_VISIBLE;
if( (pt_chevelu->m_Status & CH_ACTIF) == 0 ) if( (net->m_Status & CH_ACTIF) == 0 )
continue; continue;
GRSetDrawMode( DC, GR_XOR ); net->Draw( DrawPanel, DC, GR_XOR, wxPoint(0,0) );
GRLine( &DrawPanel->m_ClipBox, DC, pt_chevelu->m_PadStart->m_Pos.x,
pt_chevelu->m_PadStart->m_Pos.y,
pt_chevelu->m_PadEnd->m_Pos.x,
pt_chevelu->m_PadEnd->m_Pos.y,
0,
g_DesignSettings.m_RatsnestColor );
} }
} }
} }
...@@ -407,26 +395,19 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) ...@@ -407,26 +395,19 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
pt_pad = Module->m_Pads; pt_pad = Module->m_Pads;
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Next() ) for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Next() )
{ {
pt_chevelu = (RATSNEST_ITEM*) GetBoard()->m_Ratsnest; for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ )
for( ii = GetBoard()->GetNumRatsnests(); ii > 0; pt_chevelu++, ii-- )
{ {
if( (pt_chevelu->m_PadStart == pt_pad) RATSNEST_ITEM* net = &GetBoard()->m_FullRatsnest[ii];
|| (pt_chevelu->m_PadEnd == pt_pad) ) if( (net->m_PadStart == pt_pad) || (net->m_PadEnd == pt_pad) )
{ {
if( pt_chevelu->m_Status & CH_VISIBLE ) if( net->m_Status & CH_VISIBLE )
continue; continue;
pt_chevelu->m_Status |= CH_VISIBLE; net->m_Status |= CH_VISIBLE;
if( (pt_chevelu->m_Status & CH_ACTIF) == 0 ) if( (net->m_Status & CH_ACTIF) == 0 )
continue; continue;
GRSetDrawMode( DC, GR_XOR ); net->Draw( DrawPanel, DC, GR_XOR, wxPoint(0,0) );
GRLine( &DrawPanel->m_ClipBox, DC, pt_chevelu->m_PadStart->m_Pos.x,
pt_chevelu->m_PadStart->m_Pos.y,
pt_chevelu->m_PadEnd->m_Pos.x,
pt_chevelu->m_PadEnd->m_Pos.y,
0,
g_DesignSettings.m_RatsnestColor );
} }
} }
} }
...@@ -436,15 +417,13 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) ...@@ -436,15 +417,13 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
} }
} }
/* Effacement complet des selections /* Effacement complet des selections si aucun pad ou module n'a ete localise */
* si aucun pad ou module n'a ete localise */
if( (pt_pad == NULL) && (Module == NULL) ) if( (pt_pad == NULL) && (Module == NULL) )
{ {
DrawGeneralRatsnest( DC ); DrawGeneralRatsnest( DC );
pt_chevelu = (RATSNEST_ITEM*) GetBoard()->m_Ratsnest;
for( ii = GetBoard()->GetNumRatsnests(); (ii > 0) && pt_chevelu; pt_chevelu++, ii-- ) for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ )
pt_chevelu->m_Status &= ~CH_VISIBLE; GetBoard()->m_FullRatsnest[ii].m_Status &= ~CH_VISIBLE;
} }
} }
...@@ -453,27 +432,16 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) ...@@ -453,27 +432,16 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
void WinEDA_PcbFrame::Affiche_PadsNoConnect( wxDC* DC ) void WinEDA_PcbFrame::Affiche_PadsNoConnect( wxDC* DC )
/*****************************************************/ /*****************************************************/
/* Met en surbrillance les pads non encore connectes ( correspondants aux /* Hight light the unconnected pads
* chevelus actifs
*/ */
{ {
int ii; for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ )
RATSNEST_ITEM* pt_chevelu;
D_PAD* pt_pad;
pt_chevelu = (RATSNEST_ITEM*) GetBoard()->m_Ratsnest;
for( ii = GetBoard()->GetNumRatsnests(); ii > 0; pt_chevelu++, ii-- )
{ {
if( (pt_chevelu->m_Status & CH_ACTIF) == 0 ) RATSNEST_ITEM* net = &GetBoard()->m_FullRatsnest[ii];
if( (net->m_Status & CH_ACTIF) == 0 )
continue; continue;
pt_pad = pt_chevelu->m_PadStart; net->m_PadStart->Draw( DrawPanel, DC, GR_OR | GR_SURBRILL );
net->m_PadEnd->Draw( DrawPanel, DC, GR_OR | GR_SURBRILL );
if( pt_pad )
pt_pad->Draw( DrawPanel, DC, GR_OR | GR_SURBRILL );
pt_pad = pt_chevelu->m_PadEnd;
if( pt_pad )
pt_pad->Draw( DrawPanel, DC, GR_OR | GR_SURBRILL );
} }
} }
...@@ -263,10 +263,11 @@ int WinEDA_PcbFrame::LoadOnePcbFile( const wxString& FullFileName, bool Append ) ...@@ -263,10 +263,11 @@ int WinEDA_PcbFrame::LoadOnePcbFile( const wxString& FullFileName, bool Append )
/* Rebuild the new pad list (for drc and ratsnet control ...) */ /* Rebuild the new pad list (for drc and ratsnet control ...) */
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
GetBoard()->Build_Pads_Full_List();
DrawPanel->Refresh( true);
Compile_Ratsnest( NULL, true );
GetBoard()->DisplayInfo( this ); GetBoard()->DisplayInfo( this );
DrawPanel->Refresh( true);
/* reset the auto save timer */ /* reset the auto save timer */
g_SaveTime = time( NULL ); g_SaveTime = time( NULL );
......
...@@ -279,10 +279,12 @@ void WinEDA_PcbFrame::Erase_Modules( bool query ) ...@@ -279,10 +279,12 @@ void WinEDA_PcbFrame::Erase_Modules( bool query )
GetBoard()->m_Modules.DeleteAll(); GetBoard()->m_Modules.DeleteAll();
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
m_Pcb->m_Pads.clear(); // empty the pad list pointers
m_Pcb->m_NetInfo->DeleteData();
m_Pcb->m_FullRatsnest.clear(); // empty the pad list pointers
m_Pcb->m_LocalRatsnest.clear(); // empty the pad list pointers
GetBoard()->m_NbNodes = 0; GetBoard()->m_NbNodes = 0;
GetBoard()->m_NbLinks = 0;
GetBoard()->m_NbNoconnect = 0; GetBoard()->m_NbNoconnect = 0;
m_Pcb->m_Pads.clear(); // empty the pad list pointers
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
......
...@@ -208,8 +208,7 @@ int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum ) ...@@ -208,8 +208,7 @@ int WinEDA_BasePcbFrame::ReadGeneralDescrPcb( FILE* File, int* LineNum )
if( strnicmp( data, "Links", 5 ) == 0 ) if( strnicmp( data, "Links", 5 ) == 0 )
{ {
data = strtok( NULL, " =\n\r" ); // Info only, do nothing
GetBoard()->m_NbLinks = atoi( data );
continue; continue;
} }
...@@ -571,7 +570,7 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File ) ...@@ -571,7 +570,7 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
// Write old format for Layer count (for compatibility with old versions of pcbnew // Write old format for Layer count (for compatibility with old versions of pcbnew
fprintf( File, "Ly %8X\n", g_TabAllCopperLayerMask[NbLayers - 1] | ALL_NO_CU_LAYERS ); // For compatibility with old version of pcbnew fprintf( File, "Ly %8X\n", g_TabAllCopperLayerMask[NbLayers - 1] | ALL_NO_CU_LAYERS ); // For compatibility with old version of pcbnew
fprintf( File, "Links %d\n", GetBoard()->m_NbLinks ); fprintf( File, "Links %d\n", GetBoard()->GetRatsnestsCount() );
fprintf( File, "NoConn %d\n", GetBoard()->m_NbNoconnect ); fprintf( File, "NoConn %d\n", GetBoard()->m_NbNoconnect );
/* Write Bounding box info */ /* Write Bounding box info */
...@@ -872,10 +871,7 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) ...@@ -872,10 +871,7 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
BestZoom(); BestZoom();
#ifdef PCBNEW GetBoard()->m_Status_Pcb = 0;
// Build connectivity info
Compile_Ratsnest( NULL, TRUE );
#endif
return 1; return 1;
} }
......
...@@ -102,7 +102,7 @@ BEGIN_EVENT_TABLE( WinEDA_PcbFrame, WinEDA_BasePcbFrame ) ...@@ -102,7 +102,7 @@ BEGIN_EVENT_TABLE( WinEDA_PcbFrame, WinEDA_BasePcbFrame )
EVT_MENU( ID_PCB_GEN_BOM_FILE_FROM_BOARD, WinEDA_PcbFrame::RecreateBOMFileFromBoard ) EVT_MENU( ID_PCB_GEN_BOM_FILE_FROM_BOARD, WinEDA_PcbFrame::RecreateBOMFileFromBoard )
// menu Miscellaneous // menu Miscellaneous
EVT_MENU( ID_MENU_LIST_NETS, WinEDA_PcbFrame::Liste_Equipot ) EVT_MENU( ID_MENU_LIST_NETS, WinEDA_PcbFrame::ListNetsAndSelect )
EVT_MENU( ID_PCB_GLOBAL_DELETE, WinEDA_PcbFrame::Process_Special_Functions ) EVT_MENU( ID_PCB_GLOBAL_DELETE, WinEDA_PcbFrame::Process_Special_Functions )
EVT_MENU( ID_MENU_PCB_CLEAN, WinEDA_PcbFrame::Process_Special_Functions ) EVT_MENU( ID_MENU_PCB_CLEAN, WinEDA_PcbFrame::Process_Special_Functions )
EVT_MENU( ID_MENU_PCB_SWAP_LAYERS, EVT_MENU( ID_MENU_PCB_SWAP_LAYERS,
......
...@@ -40,11 +40,6 @@ bool g_TwoSegmentTrackBuild = TRUE; ...@@ -40,11 +40,6 @@ bool g_TwoSegmentTrackBuild = TRUE;
bool g_HightLigt_Status; bool g_HightLigt_Status;
extern PARAM_CFG_BASE* ParamCfgList[]; extern PARAM_CFG_BASE* ParamCfgList[];
/* A buffer used in some computations (will be removed in next cleanup code,
* DO NOT use) */
#define BUFMEMSIZE 256000 /* buffer size (in bytes) */
char* adr_lowmem = NULL;
int Angle_Rot_Module; int Angle_Rot_Module;
int ModuleSegmentWidth; int ModuleSegmentWidth;
int ModuleTextWidth; int ModuleTextWidth;
...@@ -140,15 +135,6 @@ Changing extension to .brd." ), ...@@ -140,15 +135,6 @@ Changing extension to .brd." ),
* real hotkeys in menus or tool tips */ * real hotkeys in menus or tool tips */
/* allocation de la memoire pour le fichier et autres buffers: */
/* On reserve BUFMEMSIZE octets de ram pour calcul */
adr_lowmem = (char*) MyZMalloc( BUFMEMSIZE ); /* adresse de la zone de calcul */
if( adr_lowmem == NULL )
{
printf( "No Memory, Fatal err Memory alloc\n" );
return FALSE;
}
frame = new WinEDA_PcbFrame( NULL, wxT( "PcbNew" ), frame = new WinEDA_PcbFrame( NULL, wxT( "PcbNew" ),
wxPoint( 0, 0 ), wxSize( 600, 400 ) ); wxPoint( 0, 0 ), wxSize( 600, 400 ) );
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() ); frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() );
......
This diff is collapsed.
...@@ -17,67 +17,73 @@ ...@@ -17,67 +17,73 @@
/*********************************************************/ /*********************************************************/
void WinEDA_PcbFrame::Liste_Equipot( wxCommandEvent& event ) void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event )
/*********************************************************/ /*********************************************************/
/* Display a filtered list of equipot names /** Function ListNetsAndSelect
* if an equipot is selected the corresponding tracks and pads are highlighted * called by a command event
* displays the sorted list of nets in a dialog frame
* If a net is selected, it is hightlighted
*/ */
{ {
NETINFO_ITEM* net; NETINFO_ITEM* net;
wxString msg; wxString netFilter;
WinEDA_TextFrame* List; int selection;
unsigned ii;
netFilter = wxT( "*" );
msg = wxT( "*" ); Get_Message( _( "Filter for net names:" ), _( "Net Filter" ), netFilter, this );
Get_Message( _( "Filter for net names:" ), _("Net Filter"), msg, this ); if( netFilter.IsEmpty() )
if( msg.IsEmpty() )
return; return;
List = new WinEDA_TextFrame( this, _( "List Nets" ) ); WinEDA_TextFrame List( this, _( "List Nets" ) );
for( ii = 0; ii < GetBoard()->m_NetInfo->GetCount() ; ii++ ) for( unsigned ii = 0; ii < GetBoard()->m_NetInfo->GetCount(); ii++ )
{ {
net = GetBoard()->m_NetInfo->GetItem( ii ); net = GetBoard()->m_NetInfo->GetItem( ii );
wxString Line; wxString Line;
if( !WildCompareString( msg, net->GetNetname(), false ) ) if( !WildCompareString( netFilter, net->GetNetname(), false ) )
continue; continue;
Line.Printf( wxT( "net_code = %3.3d [%.16s] " ), net->GetNet(), Line.Printf( wxT( "net_code = %3.3d [%.16s] " ), net->GetNet(),
net->GetNetname().GetData() ); net->GetNetname().GetData() );
List->Append( Line ); List.Append( Line );
} }
ii = List->ShowModal(); selection = List.ShowModal();
List->Destroy();
if( ii < 0 ) if( selection < 0 )
return; return;
for( unsigned jj = 0; jj < GetBoard()->m_NetInfo->GetCount() ; jj++ ) bool found = false;
unsigned netcode = (unsigned) selection;
// Search for the net selected.
for( unsigned ii = 0; ii < GetBoard()->m_NetInfo->GetCount(); ii++ )
{ {
net = GetBoard()->m_NetInfo->GetItem( ii ); net = GetBoard()->m_NetInfo->GetItem( ii );
if( !WildCompareString( msg, net->GetNetname(), false ) ) if( !WildCompareString( netFilter, net->GetNetname(), false ) )
continue; continue;
if( ii == jj ) if( ii == netcode )
{ {
ii = net->GetNet(); netcode = net->GetNet();
found = true;
break; break;
} }
jj++;
} }
wxClientDC dc( DrawPanel ); if( found )
{
wxClientDC dc( DrawPanel );
DrawPanel->PrepareGraphicContext( &dc ); DrawPanel->PrepareGraphicContext( &dc );
if( g_HightLigt_Status ) if( g_HightLigt_Status )
Hight_Light( &dc ); Hight_Light( &dc );
g_HightLigth_NetCode = ii; g_HightLigth_NetCode = netcode;
Hight_Light( &dc ); Hight_Light( &dc );
}
} }
...@@ -100,7 +106,7 @@ int WinEDA_PcbFrame::Select_High_Light( wxDC* DC ) ...@@ -100,7 +106,7 @@ int WinEDA_PcbFrame::Select_High_Light( wxDC* DC )
// optionally, modify the "guide" here as needed using its member functions // optionally, modify the "guide" here as needed using its member functions
m_Collector->Collect( GetBoard(), GENERAL_COLLECTOR::PadsTracksOrZones, m_Collector->Collect( GetBoard(), GENERAL_COLLECTOR::PadsTracksOrZones,
GetScreen()->RefPos( true ), guide ); GetScreen()->RefPos( true ), guide );
BOARD_ITEM* item = (*m_Collector)[0]; BOARD_ITEM* item = (*m_Collector)[0];
...@@ -109,7 +115,7 @@ int WinEDA_PcbFrame::Select_High_Light( wxDC* DC ) ...@@ -109,7 +115,7 @@ int WinEDA_PcbFrame::Select_High_Light( wxDC* DC )
switch( item->Type() ) switch( item->Type() )
{ {
case TYPE_PAD: case TYPE_PAD:
g_HightLigth_NetCode = ((D_PAD*)item)->GetNet(); g_HightLigth_NetCode = ( (D_PAD*) item )->GetNet();
Hight_Light( DC ); Hight_Light( DC );
SendMessageToEESCHEMA( item ); SendMessageToEESCHEMA( item );
return g_HightLigth_NetCode; return g_HightLigth_NetCode;
...@@ -117,14 +123,15 @@ int WinEDA_PcbFrame::Select_High_Light( wxDC* DC ) ...@@ -117,14 +123,15 @@ int WinEDA_PcbFrame::Select_High_Light( wxDC* DC )
case TYPE_TRACK: case TYPE_TRACK:
case TYPE_VIA: case TYPE_VIA:
case TYPE_ZONE: case TYPE_ZONE:
// since these classes are all derived from TRACK, use a common // since these classes are all derived from TRACK, use a common
// GetNet() function: // GetNet() function:
g_HightLigth_NetCode = ((TRACK*)item)->GetNet(); g_HightLigth_NetCode = ( (TRACK*) item )->GetNet();
Hight_Light( DC ); Hight_Light( DC );
return g_HightLigth_NetCode; return g_HightLigth_NetCode;
case TYPE_ZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
g_HightLigth_NetCode = ((ZONE_CONTAINER*)item)->GetNet(); g_HightLigth_NetCode = ( (ZONE_CONTAINER*) item )->GetNet();
Hight_Light( DC ); Hight_Light( DC );
return g_HightLigth_NetCode; return g_HightLigth_NetCode;
...@@ -151,4 +158,3 @@ void WinEDA_PcbFrame::Hight_Light( wxDC* DC ) ...@@ -151,4 +158,3 @@ void WinEDA_PcbFrame::Hight_Light( wxDC* DC )
GetBoard()->DrawHighLight( DrawPanel, DC, g_HightLigth_NetCode ); GetBoard()->DrawHighLight( DrawPanel, DC, g_HightLigth_NetCode );
} }
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