Commit efc93aa5 authored by Wayne Stambaugh's avatar Wayne Stambaugh

PCBNew locate code refactoring.

* Move various locate functions into the appropriate board item object.
* Unified best zoom for all frames derived from PCB_BASE_FRAME.
* Remove track.cpp as it is no longer needed.
* Dead code removal.
* Remove scary frame window pointer member from board item objects.
* Add draw bounding box to gerber draw item for debugging purposes.
parent ba39dac2
/* Do not modify this file, it was automatically generated by the /* Do not modify this file, it was automatically generated by the
* PNG2cpp CMake script, using a *.png file as input. * PNG2cpp CMake script, using a *.png file as input.
*/ */
#include "bitmaps.h" #include "bitmaps.h"
static const char png[] = { static const char png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x1a, 0x08, 0x06, 0x00, 0x00, 0x00, 0xa9, 0x4a, 0x4c, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x1a, 0x08, 0x06, 0x00, 0x00, 0x00, 0xa9, 0x4a, 0x4c,
0xce, 0x00, 0x00, 0x00, 0x09, 0x76, 0x70, 0x41, 0x67, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, 0xb1, 0x49, 0x44, 0x41, 0x54, 0x48, 0xc7, 0x63, 0xf8, 0xff, 0xff, 0x3f,
0x1a, 0x00, 0x07, 0xb2, 0x66, 0x2f, 0x00, 0x00, 0x01, 0x64, 0x49, 0x44, 0x41, 0x54, 0x48, 0xc7, 0x03, 0x3d, 0x30, 0x82, 0xd1, 0xc0, 0xc0, 0x24, 0x50, 0x20, 0x20, 0x40, 0x4d, 0xcc, 0x90, 0xc6,
0xd5, 0x96, 0xb1, 0x4e, 0x02, 0x41, 0x10, 0x86, 0xbf, 0xb9, 0xbb, 0xa5, 0x38, 0xa3, 0x31, 0x21, 0xc0, 0x8a, 0x61, 0x91, 0x50, 0x01, 0xd7, 0x6e, 0xa1, 0x7c, 0xce, 0x2f, 0x42, 0x05, 0x9c, 0x9f,
0xda, 0x28, 0x34, 0x1a, 0xe9, 0xa4, 0x35, 0x3c, 0x03, 0xa1, 0xb1, 0xb2, 0xb0, 0xf7, 0x21, 0xe4, 0xa8, 0x86, 0x73, 0x38, 0x9f, 0x30, 0x84, 0x32, 0xb0, 0xc1, 0x2d, 0x12, 0x49, 0x62, 0xe0, 0x15,
0x11, 0x78, 0x05, 0x0b, 0x5e, 0x81, 0xc6, 0xc6, 0x52, 0x63, 0x30, 0x34, 0x24, 0x58, 0x99, 0xa0, 0xcc, 0xe1, 0xfc, 0xa1, 0x74, 0x56, 0xe8, 0xbf, 0xd2, 0x39, 0xea, 0x61, 0x91, 0x3a, 0xee, 0x77,
0x84, 0x82, 0xc4, 0x12, 0x84, 0x53, 0xb8, 0x1d, 0x0b, 0x90, 0x28, 0x9c, 0xd1, 0x18, 0xee, 0x12, 0x82, 0x99, 0x1c, 0xb6, 0x70, 0x8b, 0x40, 0xde, 0x14, 0xca, 0xe3, 0xfc, 0x46, 0x4d, 0x4b, 0x40,
0xff, 0x6e, 0x27, 0x9b, 0xf9, 0xb2, 0xff, 0xec, 0xce, 0x8e, 0x00, 0x04, 0x41, 0x50, 0x02, 0xca, 0x58, 0xb4, 0x99, 0xe7, 0x9d, 0x40, 0x06, 0x87, 0xc3, 0xa8, 0x45, 0xa3, 0x16, 0x8d, 0x5a, 0x34,
0x02, 0x79, 0x44, 0x0c, 0x9f, 0x24, 0x00, 0x22, 0x7c, 0x89, 0x2d, 0xac, 0xbf, 0x51, 0x08, 0xb4, 0x6a, 0xd1, 0xa8, 0x45, 0xa3, 0x16, 0x8d, 0x4c, 0x8b, 0x04, 0xd3, 0x04, 0xf9, 0x69, 0x62, 0x51,
0x80, 0x8a, 0x31, 0xa6, 0x2a, 0xa3, 0xd1, 0xa8, 0x08, 0xd4, 0x54, 0x2d, 0xfd, 0xd7, 0xc1, 0xd2, 0x13, 0xd0, 0xa2, 0x4c, 0x0e, 0x7b, 0xb8, 0x45, 0x40, 0xc0, 0x08, 0xb4, 0xe8, 0xbe, 0x58, 0x3b,
0xee, 0x48, 0xd0, 0x2f, 0xe1, 0x7e, 0xca, 0xc7, 0xb8, 0x06, 0xe0, 0x4c, 0x86, 0xc3, 0xe1, 0x35, 0xcf, 0x27, 0xb1, 0x2e, 0x9e, 0x0f, 0xd4, 0xc2, 0x42, 0xb9, 0x5c, 0x1f, 0x79, 0xb3, 0x79, 0x85,
0x50, 0x38, 0xb9, 0x38, 0xa6, 0xf1, 0x54, 0xc7, 0x71, 0x1c, 0x56, 0xa5, 0x75, 0x6f, 0x83, 0xfa, 0x51, 0x5b, 0x41, 0x59, 0x9c, 0xb2, 0x02, 0x99, 0x5c, 0x01, 0xd4, 0xc4, 0x82, 0x99, 0xdc, 0x7a,
0x79, 0x93, 0x94, 0x97, 0xea, 0x7a, 0x6a, 0xed, 0xe1, 0xcb, 0xdb, 0x0b, 0xb7, 0x0f, 0x37, 0xac, 0x18, 0xcd, 0x2d, 0x5a, 0x63, 0x00, 0xe2, 0xb1, 0x17, 0xfe, 0x13, 0xe0, 0x61, 0xbb, 0x00, 0x00,
0x9d, 0xba, 0x20, 0xe1, 0xca, 0x40, 0xc1, 0x65, 0x40, 0xe3, 0xf1, 0x8e, 0xa3, 0xbd, 0xc2, 0xae, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
0xa3, 0xaa, 0x66, 0x62, 0x43, 0x5c, 0xd7, 0x99, 0x79, 0xb2, 0x3a, 0x89, 0x11, 0x42, 0x1b, 0xa2, };
0xaa, 0x38, 0xaa, 0x8a, 0xaa, 0x12, 0x97, 0x3e, 0xf2, 0x4f, 0x41, 0xd6, 0x26, 0x04, 0x4a, 0xea,
0x44, 0xc4, 0x06, 0x9a, 0xe6, 0x8e, 0xff, 0x44, 0x1a, 0x65, 0x9d, 0xc6, 0x68, 0x9d, 0xb5, 0x09, const BITMAP_OPAQUE erc_green_xpm[1] = {{ png, sizeof( png ), "erc_green_xpm" }};
0xd4, 0x68, 0x06, 0x8b, 0x1d, 0x34, 0xaf, 0x11, 0x89, 0xbe, 0xa3, 0x44, 0x40, 0xd6, 0xc6, 0x06,
0xd2, 0xa5, 0x1a, 0x41, 0xac, 0x35, 0x22, 0xf9, 0xce, 0x90, 0x64, 0xaf, 0xd3, 0xff, 0x7e, 0xeb, //EOF
0x48, 0x14, 0x34, 0x6b, 0x41, 0xe3, 0x18, 0x7d, 0x9b, 0xdb, 0xe7, 0xa9, 0x6a, 0xd3, 0x37, 0x7e,
0x21, 0xed, 0xa7, 0x19, 0x5c, 0xf5, 0x71, 0x3c, 0x89, 0x9a, 0x83, 0xfe, 0xa4, 0xf1, 0xf3, 0x84,
0xfd, 0xad, 0x03, 0x54, 0xb5, 0x2b, 0x9d, 0x76, 0xbb, 0x08, 0xd4, 0x7a, 0xfd, 0x1e, 0xf7, 0xbd,
0x56, 0xc4, 0xc7, 0x2f, 0x11, 0xa8, 0x08, 0xb8, 0x2c, 0x44, 0x45, 0xc8, 0x6c, 0x66, 0xc8, 0x6d,
0xe7, 0xa6, 0xe3, 0x16, 0x40, 0xa7, 0xdd, 0x2e, 0x01, 0x65, 0x20, 0x0f, 0x98, 0x9f, 0xa7, 0x8e,
0x08, 0xf8, 0x62, 0x4c, 0x24, 0x04, 0x5a, 0x02, 0x95, 0x9d, 0x6c, 0xb6, 0xfa, 0x0e, 0x74, 0x04,
0x22, 0x77, 0x71, 0x16, 0xc1, 0x16, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42,
0x60, 0x82,
};
const BITMAP_OPAQUE erc_green_xpm[1] = {{ png, sizeof( png ), "erc_green_xpm" }};
//EOF
This diff is collapsed.
This diff is collapsed.
...@@ -59,7 +59,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* father, ...@@ -59,7 +59,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* father,
icon.CopyFromBitmap( KiBitmap( icon_cvpcb_xpm ) ); icon.CopyFromBitmap( KiBitmap( icon_cvpcb_xpm ) );
SetIcon( icon ); SetIcon( icon );
SetBoard( new BOARD( NULL, this ) ); SetBoard( new BOARD( NULL ) );
SetScreen( new PCB_SCREEN() ); SetScreen( new PCB_SCREEN() );
LoadSettings(); LoadSettings();
...@@ -68,6 +68,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* father, ...@@ -68,6 +68,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* father,
if( (m_LastGridSizeId <= 0) || if( (m_LastGridSizeId <= 0) ||
(m_LastGridSizeId > (ID_POPUP_GRID_USER - ID_POPUP_GRID_LEVEL_1000)) ) (m_LastGridSizeId > (ID_POPUP_GRID_USER - ID_POPUP_GRID_LEVEL_1000)) )
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_500 - ID_POPUP_GRID_LEVEL_1000; m_LastGridSizeId = ID_POPUP_GRID_LEVEL_500 - ID_POPUP_GRID_LEVEL_1000;
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
// Initialize some display options // Initialize some display options
......
...@@ -41,10 +41,11 @@ ...@@ -41,10 +41,11 @@
#include "class_GERBER.h" #include "class_GERBER.h"
/**********************************************************/ #define SHOW_BOUNDING_BOX 0 // Set to 1 to draw the bounding box for debugging purposes.
GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent, GERBER_IMAGE* aGerberparams ) : GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent, GERBER_IMAGE* aGerberparams ) :
BOARD_ITEM( aParent, TYPE_GERBER_DRAW_ITEM ) BOARD_ITEM( aParent, TYPE_GERBER_DRAW_ITEM )
/**********************************************************/
{ {
m_imageParams = aGerberparams; m_imageParams = aGerberparams;
m_Layer = 0; m_Layer = 0;
...@@ -339,10 +340,8 @@ bool GERBER_DRAW_ITEM::HasNegativeItems() ...@@ -339,10 +340,8 @@ bool GERBER_DRAW_ITEM::HasNegativeItems()
} }
/*********************************************************************/
void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode,
const wxPoint& aOffset ) const wxPoint& aOffset )
/*********************************************************************/
{ {
static D_CODE dummyD_CODE( 0 ); // used when a D_CODE is not found. default D_CODE to draw a flashed item static D_CODE dummyD_CODE( 0 ); // used when a D_CODE is not found. default D_CODE to draw a flashed item
int color, alt_color; int color, alt_color;
...@@ -486,6 +485,14 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, ...@@ -486,6 +485,14 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode,
} }
break; break;
} }
#if SHOW_BOUNDING_BOX
/* Draw the component boundary box */
{
EDA_RECT boundaryBox = GetBoundingBox();
GRRect( &aPanel->m_ClipBox, aDC, boundaryBox, 0, BROWN );
}
#endif
} }
/** /**
......
...@@ -139,6 +139,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin ...@@ -139,6 +139,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
// this is due to negative objects (drawn using background color) that create artefacct // this is due to negative objects (drawn using background color) that create artefacct
// on other images when drawn on screen // on other images when drawn on screen
bool useBufferBitmap = false; bool useBufferBitmap = false;
if( (aDrawMode == GR_COPY) || ( aDrawMode == GR_OR ) ) if( (aDrawMode == GR_COPY) || ( aDrawMode == GR_OR ) )
useBufferBitmap = true; useBufferBitmap = true;
...@@ -173,9 +174,11 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin ...@@ -173,9 +174,11 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
bool doBlit = false; // this flag requests an image transfert to actual screen when true. bool doBlit = false; // this flag requests an image transfert to actual screen when true.
bool end = false; bool end = false;
for( int layer = 0; !end; layer++ ) for( int layer = 0; !end; layer++ )
{ {
int active_layer = ( (GERBVIEW_FRAME*) m_PcbFrame )->getActiveLayer(); int active_layer = ( (GERBVIEW_FRAME*) aPanel->GetParent() )->getActiveLayer();
if( layer == active_layer ) // active layer will be drawn after other layers if( layer == active_layer ) // active layer will be drawn after other layers
continue; continue;
...@@ -205,6 +208,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin ...@@ -205,6 +208,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
layerDC.SetDeviceOrigin(0,0); layerDC.SetDeviceOrigin(0,0);
layerDC.SetLogicalOrigin( 0, 0 ); layerDC.SetLogicalOrigin( 0, 0 );
layerDC.SetUserScale( 1, 1 ); layerDC.SetUserScale( 1, 1 );
if( aDrawMode == GR_COPY ) if( aDrawMode == GR_COPY )
{ {
// Use the layer bitmap itself as a mask when blitting. The bitmap // Use the layer bitmap itself as a mask when blitting. The bitmap
...@@ -212,8 +216,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin ...@@ -212,8 +216,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
layerDC.SelectObject( wxNullBitmap ); layerDC.SelectObject( wxNullBitmap );
layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor ) ); layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor ) );
layerDC.SelectObject( *layerBitmap ); layerDC.SelectObject( *layerBitmap );
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true );
&layerDC, 0, 0, wxCOPY, true );
} }
else if( aDrawMode == GR_OR ) else if( aDrawMode == GR_OR )
{ {
...@@ -224,9 +227,9 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin ...@@ -224,9 +227,9 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
// the cpu cycles needed to create the monochromatic bitmap above, and // the cpu cycles needed to create the monochromatic bitmap above, and
// the extra time needed to do bit indexing into the monochromatic bitmap // the extra time needed to do bit indexing into the monochromatic bitmap
// on the blit above. // on the blit above.
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxOR );
&layerDC, 0, 0, wxOR );
} }
// Restore actual values and clear bitmpap for next drawing // Restore actual values and clear bitmpap for next drawing
layerDC.SetDeviceOrigin( dev_org.x, dev_org.y ); layerDC.SetDeviceOrigin( dev_org.x, dev_org.y );
layerDC.SetLogicalOrigin( logical_org.x, logical_org.y ); layerDC.SetLogicalOrigin( logical_org.x, logical_org.y );
...@@ -256,7 +259,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin ...@@ -256,7 +259,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
int dcode_highlight = 0; int dcode_highlight = 0;
if( layer == ( (GERBVIEW_FRAME*) m_PcbFrame )->getActiveLayer() ) if( layer == ( (GERBVIEW_FRAME*) aPanel->GetParent() )->getActiveLayer() )
dcode_highlight = gerber->m_Selected_Tool; dcode_highlight = gerber->m_Selected_Tool;
int layerdrawMode = GR_COPY; int layerdrawMode = GR_COPY;
...@@ -277,6 +280,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin ...@@ -277,6 +280,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
if( dcode_highlight && dcode_highlight == gerb_item->m_DCode ) if( dcode_highlight && dcode_highlight == gerb_item->m_DCode )
drawMode |= GR_SURBRILL; drawMode |= GR_SURBRILL;
gerb_item->Draw( aPanel, plotDC, drawMode ); gerb_item->Draw( aPanel, plotDC, drawMode );
doBlit = true; doBlit = true;
} }
...@@ -297,14 +301,12 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin ...@@ -297,14 +301,12 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
layerDC.SelectObject( wxNullBitmap ); layerDC.SelectObject( wxNullBitmap );
layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor ) ); layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor ) );
layerDC.SelectObject( *layerBitmap ); layerDC.SelectObject( *layerBitmap );
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true );
&layerDC, 0, 0, wxCOPY, true );
} }
else if( aDrawMode == GR_OR ) else if( aDrawMode == GR_OR )
{ {
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxOR );
&layerDC, 0, 0, wxOR );
} }
} }
......
...@@ -47,7 +47,7 @@ GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME * aFrame, FILE * aFile ...@@ -47,7 +47,7 @@ GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME * aFrame, FILE * aFile
{ {
m_gerbview_frame = aFrame; m_gerbview_frame = aFrame;
m_file = aFile; m_file = aFile;
m_pcb = new BOARD( NULL, m_gerbview_frame ); m_pcb = new BOARD( NULL );
} }
GBR_TO_PCB_EXPORTER::~GBR_TO_PCB_EXPORTER() GBR_TO_PCB_EXPORTER::~GBR_TO_PCB_EXPORTER()
......
...@@ -44,7 +44,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father, ...@@ -44,7 +44,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father,
m_SelLayerBox = NULL; m_SelLayerBox = NULL;
m_DCodeSelector = NULL; m_DCodeSelector = NULL;
m_displayMode = 0; m_displayMode = 0;
m_drillFileHistory.SetBaseId(ID_GERBVIEW_DRILL_FILE1); m_drillFileHistory.SetBaseId( ID_GERBVIEW_DRILL_FILE1 );
if( DrawPanel ) if( DrawPanel )
DrawPanel->m_Block_Enable = true; DrawPanel->m_Block_Enable = true;
...@@ -56,7 +56,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father, ...@@ -56,7 +56,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father,
SetScreen( ScreenPcb ); SetScreen( ScreenPcb );
SetBoard( new BOARD( NULL, this ) ); SetBoard( new BOARD( NULL ) );
GetBoard()->SetEnabledLayers( FULL_LAYERS ); // All 32 layers enabled at first. GetBoard()->SetEnabledLayers( FULL_LAYERS ); // All 32 layers enabled at first.
GetBoard()->SetVisibleLayers( FULL_LAYERS ); // All 32 layers visible. GetBoard()->SetVisibleLayers( FULL_LAYERS ); // All 32 layers visible.
...@@ -74,7 +74,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father, ...@@ -74,7 +74,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father,
// initialize parameters in m_LayersManager // initialize parameters in m_LayersManager
LoadSettings(); LoadSettings();
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();
...@@ -144,34 +144,6 @@ void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -144,34 +144,6 @@ void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
} }
double GERBVIEW_FRAME::BestZoom()
{
// gives a minimal value to zoom, if no item in list
if( GetBoard()->m_Drawings == NULL )
return 160.0;
EDA_RECT bbox;
BOARD_ITEM* item = GetBoard()->m_Drawings;
bbox = ( (GERBER_DRAW_ITEM*) item )->GetBoundingBox();
for( ; item; item = item->Next() )
{
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
bbox.Merge( gerb_item->GetBoundingBox() );
}
wxSize size = DrawPanel->GetClientSize();
double x = (double) bbox.GetWidth() / (double) size.x;
double y = (double) bbox.GetHeight() / (double) size.y;
GetScreen()->SetScrollCenterPosition( bbox.Centre() );
double best_zoom = MAX( x, y );
return best_zoom;
}
void GERBVIEW_FRAME::LoadSettings() void GERBVIEW_FRAME::LoadSettings()
{ {
wxConfig* config = wxGetApp().m_EDA_Config; wxConfig* config = wxGetApp().m_EDA_Config;
......
...@@ -52,8 +52,8 @@ private: ...@@ -52,8 +52,8 @@ private:
// a gerber file // a gerber file
public: GERBVIEW_FRAME( wxWindow* father, const wxString& title, public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
const wxPoint& pos, const wxSize& size, const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
~GERBVIEW_FRAME(); ~GERBVIEW_FRAME();
...@@ -68,7 +68,6 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title, ...@@ -68,7 +68,6 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
double BestZoom();
/** /**
* Function ReportMessage * Function ReportMessage
......
...@@ -357,8 +357,7 @@ public: ...@@ -357,8 +357,7 @@ public:
int m_Flags; // flags for editing and other uses. int m_Flags; // flags for editing and other uses.
unsigned long m_TimeStamp; // Time stamp used for logical links unsigned long m_TimeStamp; // Time stamp used for logical links
int m_Selected; /* Used by block commands, and selective int m_Selected; /* Used by block commands, and selective editing */
* editing */
// member used in undo/redo function // member used in undo/redo function
EDA_ITEM* m_Image; // Link to an image copy to save a copy of EDA_ITEM* m_Image; // Link to an image copy to save a copy of
......
...@@ -182,7 +182,6 @@ set(PCBNEW_SRCS ...@@ -182,7 +182,6 @@ set(PCBNEW_SRCS
tool_pcb.cpp tool_pcb.cpp
toolbars_update_user_interface.cpp toolbars_update_user_interface.cpp
tracepcb.cpp tracepcb.cpp
track.cpp
tr_modif.cpp tr_modif.cpp
trpiste.cpp trpiste.cpp
work.cpp work.cpp
......
...@@ -39,7 +39,7 @@ void PCB_EDIT_FRAME::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On ) ...@@ -39,7 +39,7 @@ void PCB_EDIT_FRAME::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On )
return; return;
DrawPanel->CrossHairOff( DC ); // Erase cursor shape DrawPanel->CrossHairOff( DC ); // Erase cursor shape
Track = MarkTrace( GetBoard(), track, &nb_segm, NULL, NULL, true ); Track = GetBoard()->MarkTrace( track, &nb_segm, NULL, NULL, true );
DrawTraces( DrawPanel, DC, Track, nb_segm, GR_OR | GR_SURBRILL ); DrawTraces( DrawPanel, DC, Track, nb_segm, GR_OR | GR_SURBRILL );
for( ; (Track != NULL) && (nb_segm > 0); nb_segm-- ) for( ; (Track != NULL) && (nb_segm > 0); nb_segm-- )
......
...@@ -105,32 +105,48 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard ) ...@@ -105,32 +105,48 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
double PCB_BASE_FRAME::BestZoom( void ) double PCB_BASE_FRAME::BestZoom( void )
{ {
int dx, dy; int dx, dy;
double ii, jj; double zx, zy;
wxSize size; wxSize size;
wxPoint center;
if( m_Pcb == NULL ) if( m_Pcb != NULL && m_Pcb->ComputeBoundingBox() )
return 32.0; {
dx = m_Pcb->m_BoundaryBox.GetWidth();
dy = m_Pcb->m_BoundaryBox.GetHeight();
center = m_Pcb->m_BoundaryBox.Centre();
}
else
{
if( m_Draw_Sheet_Ref )
{
dx = GetScreen()->ReturnPageSize().x;
dy = GetScreen()->ReturnPageSize().y;
}
else
{
dx = GetScreen()->ReturnPageSize().x;
dy = GetScreen()->ReturnPageSize().y;
}
m_Pcb->ComputeBoundingBox(); center = wxPoint( dx / 2, dy / 2 );
}
dx = m_Pcb->m_BoundaryBox.GetWidth();
dy = m_Pcb->m_BoundaryBox.GetHeight();
size = DrawPanel->GetClientSize(); size = DrawPanel->GetClientSize();
if( size.x ) if( size.x )
ii = (double)(dx + ( size.x / 2) ) / (double) size.x; zx = (double) dx / (double) size.x;
else else
ii = 32.0; zx = 32.0;
if ( size.y ) if ( size.y )
jj = (double)( dy + (size.y / 2) ) / (double) size.y; zy = (double) dy / (double) size.y;
else else
jj = 32.0; zy = 32.0;
double bestzoom = MAX( ii, jj ); double bestzoom = MAX( zx, zy );
GetScreen()->SetScrollCenterPosition( m_Pcb->m_BoundaryBox.Centre() ); GetScreen()->SetScrollCenterPosition( center );
return bestzoom ; return bestzoom;
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -819,6 +819,22 @@ D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const ...@@ -819,6 +819,22 @@ D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const
} }
D_PAD* MODULE::GetPad( const wxPoint& aPosition, int aLayerMask )
{
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
/* ... and on the correct layer. */
if( ( pad->m_layerMask & aLayerMask ) == 0 )
continue;
if( pad->HitTest( aPosition ) )
return pad;
}
return NULL;
}
// see class_module.h // see class_module.h
SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData, SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ) const KICAD_T scanTypes[] )
......
...@@ -298,6 +298,16 @@ public: ...@@ -298,6 +298,16 @@ public:
D_PAD* FindPadByName( const wxString& aPadName ) const; D_PAD* FindPadByName( const wxString& aPadName ) const;
/**
* Function GetPad
* return a pad at \a aPosition on \a aLayerMask
*
* @param aPosition A wxPoint object containing the position to hit test.
* @param aLayerMask A layer or layers to mask the hit test.
* @return A pointer to a D_PAD object if found or NULL if not found.
*/
D_PAD* GetPad( const wxPoint& aPosition, int aLayerMask = ALL_LAYERS );
/** /**
* Function Visit * Function Visit
* should be re-implemented for each derived class in order to handle * should be re-implemented for each derived class in order to handle
......
This diff is collapsed.
/*******************************************************************/ /**
/* class_track.h: definitions relatives to tracks, vias and zones */ * @file class_track.h
/*******************************************************************/ * @brief Class definitions for tracks, vias, and zones.
*/
#ifndef CLASS_TRACK_H #ifndef CLASS_TRACK_H
#define CLASS_TRACK_H #define CLASS_TRACK_H
...@@ -16,6 +17,9 @@ ...@@ -16,6 +17,9 @@
* to the near neighbor internal layer */ * to the near neighbor internal layer */
#define VIA_NOT_DEFINED 0 /* not yet used */ #define VIA_NOT_DEFINED 0 /* not yet used */
#define IGNORE_LAYERS -1
/***/ /***/
class TRACK : public BOARD_CONNECTED_ITEM class TRACK : public BOARD_CONNECTED_ITEM
...@@ -105,7 +109,7 @@ public: ...@@ -105,7 +109,7 @@ public:
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/** /**
* Function GetBestInsertPoint * Function GetBestInsertPoint
...@@ -115,24 +119,24 @@ public: ...@@ -115,24 +119,24 @@ public:
* @param aPcb The BOARD to search for the insertion point. * @param aPcb The BOARD to search for the insertion point.
* @return TRACK* - the item found in the linked list (or NULL if no track) * @return TRACK* - the item found in the linked list (or NULL if no track)
*/ */
TRACK* GetBestInsertPoint( BOARD* aPcb ); TRACK* GetBestInsertPoint( BOARD* aPcb );
/* Search (within the track linked list) the first segment matching the netcode /* Search (within the track linked list) the first segment matching the netcode
* ( the linked list is always sorted by net codes ) * ( the linked list is always sorted by net codes )
*/ */
TRACK* GetStartNetCode( int NetCode ); TRACK* GetStartNetCode( int NetCode );
/* Search (within the track linked list) the last segment matching the netcode /* Search (within the track linked list) the last segment matching the netcode
* ( the linked list is always sorted by net codes ) * ( the linked list is always sorted by net codes )
*/ */
TRACK* GetEndNetCode( int NetCode ); TRACK* GetEndNetCode( int NetCode );
/** /**
* Function GetLength * Function GetLength
* returns the length of the track using the hypotenuse calculation. * returns the length of the track using the hypotenuse calculation.
* @return double - the length of the track * @return double - the length of the track
*/ */
double GetLength() const double GetLength() const
{ {
int dx = m_Start.x - m_End.x; int dx = m_Start.x - m_End.x;
int dy = m_Start.y - m_End.y; int dy = m_Start.y - m_End.y;
...@@ -141,9 +145,53 @@ public: ...@@ -141,9 +145,53 @@ public:
} }
/**
* Function GetEndSegments
* get the end points connected to the track.
*
* @param aCount The maximum number of connected segments to test.
* @param aStartTrack The beginning segment connected to the trace.
* @param aEndTrack The end segment connected to the trace.
* @return A 1 if the end points are valid or a 0 when a trace is a closed loop.
*/
int GetEndSegments( int aCount, TRACK** aStartTrack, TRACK** aEndTrack );
/**
* Function GetTrace
* returns a trace segment or via at \a aPosition on \a aLayer starting from this
* trace.
*
* @param aPosition The wxPoint to HitTest() against.
* @param aLayer The layer to search. Use -1 for a don't care.
* @return A pointer to the TRACK or SEGVIA object if found, else NULL.
*/
TRACK* GetTrace( const wxPoint& aPosition, int aLayer );
/**
* Function GetVia
* finds the first SEGVIA object at \a aPosition on \a aLayer starting at the trace.
*
* @param aPosition The wxPoint to HitTest() against.
* @param aLayer The layer to match, pass -1 for a don't care.
* @return A pointer to a TRACK object ( actually a SEGVIA ) if found, else NULL.
*/
TRACK* GetVia( const wxPoint& aPosition, int aLayer = IGNORE_LAYERS );
/**
* Function GetVia
* finds the first SEGVIA object at \a aPosition on \a aLayer starting at the trace
* and ending at \a aEndTrace.
*
* @param aEndTrace Pointer to the last TRACK object to end search.
* @param aPosition The wxPoint to HitTest() against.
* @param aLayer The layer to match, pass -1 for a don't care.
* @return A pointer to a TRACK object ( actually a SEGVIA ) if found, else NULL.
*/
TRACK* GetVia( TRACK* aEndTrace, const wxPoint& aPosition, int aLayer );
/* Display on screen: */ /* Display on screen: */
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode,
const wxPoint& aOffset = ZeroOffset ); const wxPoint& aOffset = ZeroOffset );
/* divers */ /* divers */
int Shape() const { return m_Shape & 0xFF; } int Shape() const { return m_Shape & 0xFF; }
...@@ -196,15 +244,20 @@ public: ...@@ -196,15 +244,20 @@ public:
* TRACK segment or SEGVIA physically resides. * TRACK segment or SEGVIA physically resides.
* @return int - a layer mask, see pcbstruct.h's LAYER_BACK, etc. * @return int - a layer mask, see pcbstruct.h's LAYER_BACK, etc.
*/ */
int ReturnMaskLayer(); int ReturnMaskLayer();
int IsPointOnEnds( const wxPoint& point, int min_dist = 0 ); /**
* Function IsPointOnEnds
* returns #STARTPOINT or #ENDPOINT if the start or end point is within \a aDistance
* of \a aPosition otherwise 0 is returned.
*/
int IsPointOnEnds( const wxPoint& aPosition, int aDistance = 0 );
/** /**
* Function IsNull * Function IsNull
* returns true if segment length is zero. * returns true if segment length is zero.
*/ */
bool IsNull(); bool IsNull();
/** /**
* Function DisplayInfo * Function DisplayInfo
...@@ -214,7 +267,7 @@ public: ...@@ -214,7 +267,7 @@ public:
* Display info about the track segment and the full track length * Display info about the track segment and the full track length
* @param frame A EDA_DRAW_FRAME in which to print status information. * @param frame A EDA_DRAW_FRAME in which to print status information.
*/ */
void DisplayInfo( EDA_DRAW_FRAME* frame ); void DisplayInfo( EDA_DRAW_FRAME* frame );
/** /**
* Function DisplayInfoBase * Function DisplayInfoBase
...@@ -223,13 +276,13 @@ public: ...@@ -223,13 +276,13 @@ public:
* Display info about the track segment only, and does not calculate the full track length * Display info about the track segment only, and does not calculate the full track length
* @param frame A EDA_DRAW_FRAME in which to print status information. * @param frame A EDA_DRAW_FRAME in which to print status information.
*/ */
void DisplayInfoBase( EDA_DRAW_FRAME* frame ); void DisplayInfoBase( EDA_DRAW_FRAME* frame );
/** /**
* Function ShowWidth * Function ShowWidth
* returns the width of the track in displayable user units. * returns the width of the track in displayable user units.
*/ */
wxString ShowWidth() const; wxString ShowWidth() const;
/** /**
* Function Visit * Function Visit
...@@ -244,8 +297,8 @@ public: ...@@ -244,8 +297,8 @@ public:
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
* else SCAN_CONTINUE, and determined by the inspector. * else SCAN_CONTINUE, and determined by the inspector.
*/ */
SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData, SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ); const KICAD_T scanTypes[] );
/** /**
...@@ -254,7 +307,7 @@ public: ...@@ -254,7 +307,7 @@ public:
* @param refPos A wxPoint to test * @param refPos A wxPoint to test
* @return bool - true if a hit, else false * @return bool - true if a hit, else false
*/ */
bool HitTest( const wxPoint& refPos ); bool HitTest( const wxPoint& refPos );
/** /**
* Function HitTest (overlaid) * Function HitTest (overlaid)
...@@ -263,7 +316,7 @@ public: ...@@ -263,7 +316,7 @@ public:
* @param refArea an EDA_RECT to test * @param refArea an EDA_RECT to test
* @return bool - true if a hit, else false * @return bool - true if a hit, else false
*/ */
bool HitTest( EDA_RECT& refArea ); bool HitTest( EDA_RECT& refArea );
/** /**
* Function GetClass * Function GetClass
...@@ -348,9 +401,8 @@ public: ...@@ -348,9 +401,8 @@ public:
} }
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode,
const wxPoint& aOffset = ZeroOffset ); const wxPoint& aOffset = ZeroOffset );
/** /**
* Function IsOnLayer * Function IsOnLayer
...@@ -359,10 +411,28 @@ public: ...@@ -359,10 +411,28 @@ public:
* @param aLayer the layer to test for. * @param aLayer the layer to test for.
* @return bool - true if on given layer, else false. * @return bool - true if on given layer, else false.
*/ */
bool IsOnLayer( int aLayer ) const; bool IsOnLayer( int aLayer ) const;
void SetLayerPair( int top_layer, int bottom_layer ); /**
void ReturnLayerPair( int* top_layer, int* bottom_layer ) const; * Function SetLayerPair
* set the .m_Layer member for a via m_Layer contains the 2 layers :
* top layer and bottom layer used by the via.
* The via connect all layers from top layer to bottom layer
* 4 bits for the first layer and 4 next bits for the second layer
* @param top_layer = first layer connected by the via
* @param bottom_layer = last layer connected by the via
*/
void SetLayerPair( int top_layer, int bottom_layer );
/**
* Function ReturnLayerPair
* return the 2 layers used by the via (the via actually uses all layers between
* these 2 layers)
*
* @param top_layer = pointer to the first layer (can be null)
* @param bottom_layer = pointer to the last layer (can be null)
*/
void ReturnLayerPair( int* top_layer, int* bottom_layer ) const;
/** /**
* Function GetPosition * Function GetPosition
...@@ -375,7 +445,7 @@ public: ...@@ -375,7 +445,7 @@ public:
} }
void SetPosition( const wxPoint& aPoint ) { m_Start = aPoint; m_End = aPoint; } void SetPosition( const wxPoint& aPoint ) { m_Start = aPoint; m_End = aPoint; }
/** /**
* Function GetClass * Function GetClass
......
...@@ -857,43 +857,26 @@ bool ZONE_CONTAINER::HitTest( const wxPoint& refPos ) ...@@ -857,43 +857,26 @@ bool ZONE_CONTAINER::HitTest( const wxPoint& refPos )
} }
/** bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& aPosition, int aMinDistance )
* Function HitTestForCorner
* tests if the given wxPoint near a corner, or near the segment define by 2 corners.
* Choose the nearest corner
* "near" means grid size (or CORNER_MIN_DIST if grid is not known)
* Set m_CornerSelection to corner index in .m_Poly-&gtcorner or -1 if no corner found
* @return true if a corner found
* @param refPos : A wxPoint to test
*/
bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )
{ {
m_CornerSelection = -1; // Set to not found m_CornerSelection = -1; // Set to not found
#define CORNER_MIN_DIST 100 // distance (in internal units) to detect a corner in a zone outline int x, y;
int min_dist = CORNER_MIN_DIST + 1; int closestDistance = aMinDistance;
if( GetBoard() && GetBoard()->m_PcbFrame )
{
// Use grid size because it is known
wxRealPoint grid = GetBoard()->m_PcbFrame->DrawPanel->GetGrid();
min_dist = wxRound( MIN( grid.x, grid.y ) );
}
wxPoint delta;
unsigned lim = m_Poly->corner.size(); unsigned lim = m_Poly->corner.size();
for( unsigned item_pos = 0; item_pos < lim; item_pos++ ) for( unsigned item_pos = 0; item_pos < lim; item_pos++ )
{ {
delta.x = refPos.x - m_Poly->corner[item_pos].x; x = aPosition.x - m_Poly->corner[item_pos].x;
delta.y = refPos.y - m_Poly->corner[item_pos].y; y = aPosition.y - m_Poly->corner[item_pos].y;
// Calculate a distance: // Calculate a distance:
int dist = MAX( abs( delta.x ), abs( delta.y ) ); int dist = MAX( abs( x ), abs( y ) );
if( dist < min_dist ) // this corner is a candidate: if( dist < closestDistance ) // this corner is a candidate:
{ {
m_CornerSelection = item_pos; m_CornerSelection = item_pos;
min_dist = dist; closestDistance = dist;
} }
} }
...@@ -901,31 +884,13 @@ bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos ) ...@@ -901,31 +884,13 @@ bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )
} }
/** bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& aPosition, int aMinDistance )
* Function HitTestForEdge
* tests if the given wxPoint near a corner, or near the segment define by 2 corners.
* choose the nearest segment
* "near" means grid size (or EDGE_MIN_DIST if grid is not known)
* Set m_CornerSelection to -1 if nothing found, or index of the starting corner of edge
* in .m_Poly-&gtcorner
* @return true if found
* @param refPos : A wxPoint to test
*/
bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
{ {
unsigned lim = m_Poly->corner.size(); unsigned lim = m_Poly->corner.size();
m_CornerSelection = -1; // Set to not found m_CornerSelection = -1; // Set to not found
#define EDGE_MIN_DIST 200 // distance (in internal units) to detect a zone outline int closestDistance = aMinDistance;
int min_dist = EDGE_MIN_DIST+1;
if( GetBoard() && GetBoard()->m_PcbFrame )
{
// Use grid size because it is known
wxRealPoint grid = GetBoard()->m_PcbFrame->DrawPanel->GetGrid();
min_dist = wxRound( MIN( grid.x, grid.y ) );
}
unsigned first_corner_pos = 0; unsigned first_corner_pos = 0;
...@@ -945,17 +910,17 @@ bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos ) ...@@ -945,17 +910,17 @@ bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
} }
/* test the dist between segment and ref point */ /* test the dist between segment and ref point */
int dist = (int) GetPointToLineSegmentDistance( refPos.x, int dist = (int) GetPointToLineSegmentDistance( aPosition.x,
refPos.y, aPosition.y,
m_Poly->corner[item_pos].x, m_Poly->corner[item_pos].x,
m_Poly->corner[item_pos].y, m_Poly->corner[item_pos].y,
m_Poly->corner[end_segm].x, m_Poly->corner[end_segm].x,
m_Poly->corner[end_segm].y ); m_Poly->corner[end_segm].y );
if( dist < min_dist ) if( dist < closestDistance )
{ {
m_CornerSelection = item_pos; m_CornerSelection = item_pos;
min_dist = dist; closestDistance = dist;
} }
} }
......
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
#include "class_zone_setting.h" #include "class_zone_setting.h"
#define CORNER_MIN_DIST 100 // distance (in internal units) to detect a corner in a zone outline
#define EDGE_MIN_DIST 200 // distance (in internal units) to detect a zone outline
/* a small class used when filling areas with segments */ /* a small class used when filling areas with segments */
class SEGMENT class SEGMENT
{ {
...@@ -246,21 +250,23 @@ public: ...@@ -246,21 +250,23 @@ public:
/** /**
* Function HitTestForCorner * Function HitTestForCorner
* tests if the given wxPoint near a corner * tests if \a aPosition is with \a aDistance a zone corner.
* Set m_CornerSelection to -1 if nothing found, or index of corner * Set m_CornerSelection to -1 if nothing found, or index of corner
* @return true if found * @return true if found
* @param refPos : A wxPoint to test * @param aPosition A wxPoint to test
* @param aMinDistance The minimum distance with \a aPosition that will still yield a hit.
*/ */
bool HitTestForCorner( const wxPoint& refPos ); bool HitTestForCorner( const wxPoint& aPosition, int aMinDistance = CORNER_MIN_DIST );
/** /**
* Function HitTestForEdge * Function HitTestForEdge
* tests if the given wxPoint is near a segment defined by 2 corners. * tests if the given wxPoint is near a segment defined by 2 corners.
* Set m_CornerSelection to -1 if nothing found, or index of the starting corner of vertice * Set m_CornerSelection to -1 if nothing found, or index of the starting corner of vertice
* @return true if found * @return true if found
* @param refPos : A wxPoint to test * @param aPosition A wxPoint to test
* @param aMinDistance The minimum distance with \a aPosition that will still yield a hit.
*/ */
bool HitTestForEdge( const wxPoint& refPos ); bool HitTestForEdge( const wxPoint& aPosition, int aMinDistance = EDGE_MIN_DIST );
/** /**
* Function HitTest (overlayed) * Function HitTest (overlayed)
......
...@@ -153,7 +153,7 @@ void clean_vias( BOARD * aPcb ) ...@@ -153,7 +153,7 @@ void clean_vias( BOARD * aPcb )
if( track->m_Shape != VIA_THROUGH ) if( track->m_Shape != VIA_THROUGH )
continue; continue;
D_PAD* pad = Fast_Locate_Pad_Connecte( aPcb, track->m_Start, ALL_CU_LAYERS ); D_PAD* pad = aPcb->GetPadFast( track->m_Start, ALL_CU_LAYERS );
if( pad && (pad->m_layerMask & EXTERNAL_LAYERS) == EXTERNAL_LAYERS ) // redundant Via if( pad && (pad->m_layerMask & EXTERNAL_LAYERS) == EXTERNAL_LAYERS ) // redundant Via
{ {
...@@ -225,7 +225,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC ) ...@@ -225,7 +225,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC )
D_PAD* pad; D_PAD* pad;
pad = Fast_Locate_Pad_Connecte( frame->GetBoard(), segment->m_Start, masklayer ); pad = frame->GetBoard()->GetPadFast( segment->m_Start, masklayer );
if( pad != NULL ) if( pad != NULL )
{ {
...@@ -233,7 +233,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC ) ...@@ -233,7 +233,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC )
type_end |= START_ON_PAD; type_end |= START_ON_PAD;
} }
pad = Fast_Locate_Pad_Connecte( frame->GetBoard(), segment->m_End, masklayer ); pad = frame->GetBoard()->GetPadFast( segment->m_End, masklayer );
if( pad != NULL ) if( pad != NULL )
{ {
...@@ -601,8 +601,7 @@ static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extre ...@@ -601,8 +601,7 @@ static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extre
if( extremite == START ) if( extremite == START )
{ {
/* We do not have a pad */ /* We do not have a pad */
if( Fast_Locate_Pad_Connecte( Pcb, pt_ref->m_Start, if( Pcb->GetPadFast( pt_ref->m_Start, g_TabOneLayerMask[pt_ref->GetLayer()] ) )
g_TabOneLayerMask[pt_ref->GetLayer()] ) )
return NULL; return NULL;
/* change the common point coordinate of pt_segm tu use the other point /* change the common point coordinate of pt_segm tu use the other point
...@@ -621,8 +620,7 @@ static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extre ...@@ -621,8 +620,7 @@ static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extre
else /* extremite == END */ else /* extremite == END */
{ {
/* We do not have a pad */ /* We do not have a pad */
if( Fast_Locate_Pad_Connecte( Pcb, pt_ref->m_End, if( Pcb->GetPadFast( pt_ref->m_End, g_TabOneLayerMask[pt_ref->GetLayer()] ) )
g_TabOneLayerMask[pt_ref->GetLayer()] ) )
return NULL; return NULL;
/* change the common point coordinate of pt_segm tu use the other point /* change the common point coordinate of pt_segm tu use the other point
...@@ -782,7 +780,7 @@ static void Gen_Raccord_Track( PCB_EDIT_FRAME* frame, wxDC* DC ) ...@@ -782,7 +780,7 @@ static void Gen_Raccord_Track( PCB_EDIT_FRAME* frame, wxDC* DC )
{ {
TRACK* newTrack; TRACK* newTrack;
other = GetTrace( other, segment->m_Start, layerMask ); other = frame->GetBoard()->GetTrace( other, segment->m_Start, layerMask );
if( other == NULL ) if( other == NULL )
break; break;
...@@ -831,7 +829,7 @@ static void Gen_Raccord_Track( PCB_EDIT_FRAME* frame, wxDC* DC ) ...@@ -831,7 +829,7 @@ static void Gen_Raccord_Track( PCB_EDIT_FRAME* frame, wxDC* DC )
{ {
TRACK* newTrack; TRACK* newTrack;
other = GetTrace( other, segment->m_End, layerMask ); other = frame->GetBoard()->GetTrace( other, segment->m_End, layerMask );
if( other == NULL ) if( other == NULL )
break; break;
...@@ -980,7 +978,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame, wxDC* DC ) ...@@ -980,7 +978,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame, wxDC* DC )
if( frame->DrawPanel->m_AbortRequest ) if( frame->DrawPanel->m_AbortRequest )
return; return;
pad = Locate_Pad_Connecte( frame->GetBoard(), segment, START ); pad = frame->GetBoard()->GetPad( segment, START );
if( pad ) if( pad )
{ {
...@@ -1004,7 +1002,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame, wxDC* DC ) ...@@ -1004,7 +1002,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame, wxDC* DC )
} }
} }
pad = Locate_Pad_Connecte( frame->GetBoard(), segment, END ); pad = frame->GetBoard()->GetPad( segment, END );
if( pad ) if( pad )
{ {
......
...@@ -562,28 +562,6 @@ static D_PAD* SuperFast_Locate_Pad_Connecte( BOARD* aPcb, LISTE_PAD* pt_liste, ...@@ -562,28 +562,6 @@ static D_PAD* SuperFast_Locate_Pad_Connecte( BOARD* aPcb, LISTE_PAD* pt_liste,
} }
/**
* Function SortPadsByXCoord
* is used to Sort a pad list by x coordinate value.
*/
static int SortPadsByXCoord( const void* pt_ref, const void* pt_comp )
{
D_PAD* ref = *(LISTE_PAD*) pt_ref;
D_PAD* comp = *(LISTE_PAD*) pt_comp;
return ref->m_Pos.x - comp->m_Pos.x;
}
void CreateSortedPadListByXCoord( BOARD* aBoard, std::vector<D_PAD*>* aVector )
{
aVector->insert( aVector->end(), aBoard->m_NetInfo->m_PadsFullList.begin(),
aBoard->m_NetInfo->m_PadsFullList.end() );
qsort( &(*aVector)[0], aBoard->GetPadsCount(), sizeof( D_PAD*), SortPadsByXCoord );
}
/* search connections between tracks and pads, and propagate pad net codes to the track segments /* search connections between tracks and pads, and propagate pad net codes to the track segments
* This is a 2 pass computation. * This is a 2 pass computation.
* First: * First:
...@@ -622,7 +600,7 @@ void PCB_BASE_FRAME::RecalculateAllTracksNetcode() ...@@ -622,7 +600,7 @@ void PCB_BASE_FRAME::RecalculateAllTracksNetcode()
/**************************************************************/ /**************************************************************/
/* Pass 1: search the connections between track ends and pads */ /* Pass 1: search the connections between track ends and pads */
/**************************************************************/ /**************************************************************/
CreateSortedPadListByXCoord( m_Pcb, &sortedPads ); m_Pcb->CreateSortedPadListByXCoord( &sortedPads );
/* Reset variables and flags used in computation */ /* Reset variables and flags used in computation */
pt_trace = m_Pcb->m_Track; pt_trace = m_Pcb->m_Track;
......
...@@ -176,8 +176,8 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm ) ...@@ -176,8 +176,8 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
if( pt_segm == NULL ) if( pt_segm == NULL )
return; return;
TRACK* trackList = MarkTrace( GetBoard(), pt_segm, &segments_to_delete_count, TRACK* trackList = GetBoard()->MarkTrace( pt_segm, &segments_to_delete_count,
NULL, NULL, true ); NULL, NULL, true );
if( segments_to_delete_count == 0 ) if( segments_to_delete_count == 0 )
return; return;
......
...@@ -411,7 +411,7 @@ void DRC::testPad2Pad() ...@@ -411,7 +411,7 @@ void DRC::testPad2Pad()
{ {
std::vector<D_PAD*> sortedPads; std::vector<D_PAD*> sortedPads;
CreateSortedPadListByXCoord( m_pcb, &sortedPads ); m_pcb->CreateSortedPadListByXCoord( &sortedPads );
// find the max size of the pads (used to stop the test) // find the max size of the pads (used to stop the test)
int max_size = 0; int max_size = 0;
...@@ -420,7 +420,8 @@ void DRC::testPad2Pad() ...@@ -420,7 +420,8 @@ void DRC::testPad2Pad()
{ {
D_PAD* pad = sortedPads[i]; D_PAD* pad = sortedPads[i];
if( pad->m_ShapeMaxRadius > max_size ) // m_ShapeMaxRadius is the radius value of the circle containing the pad // m_ShapeMaxRadius is the radius value of the circle containing the pad.
if( pad->m_ShapeMaxRadius > max_size )
max_size = pad->m_ShapeMaxRadius; max_size = pad->m_ShapeMaxRadius;
} }
......
...@@ -1002,7 +1002,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -1002,7 +1002,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
wxPoint pos = GetScreen()->GetCrossHairPosition(); wxPoint pos = GetScreen()->GetCrossHairPosition();
track->Draw( DrawPanel, &dc, GR_XOR ); track->Draw( DrawPanel, &dc, GR_XOR );
PICKED_ITEMS_LIST itemsListPicker; PICKED_ITEMS_LIST itemsListPicker;
TRACK* newtrack = CreateLockPoint( GetBoard(), pos, track, &itemsListPicker ); TRACK* newtrack = GetBoard()->CreateLockPoint( pos, track, &itemsListPicker );
SaveCopyInUndoList( itemsListPicker, UR_UNSPECIFIED ); SaveCopyInUndoList( itemsListPicker, UR_UNSPECIFIED );
track->Draw( DrawPanel, &dc, GR_XOR ); track->Draw( DrawPanel, &dc, GR_XOR );
newtrack->Draw( DrawPanel, &dc, GR_XOR ); newtrack->Draw( DrawPanel, &dc, GR_XOR );
......
...@@ -166,7 +166,7 @@ void PCB_EDIT_FRAME::Edit_Track_Width( wxDC* aDC, TRACK* aTrackSegment ) ...@@ -166,7 +166,7 @@ void PCB_EDIT_FRAME::Edit_Track_Width( wxDC* aDC, TRACK* aTrackSegment )
if( aTrackSegment == NULL ) if( aTrackSegment == NULL )
return; return;
pt_track = MarkTrace( GetBoard(), aTrackSegment, &nb_segm, NULL, NULL, true ); pt_track = GetBoard()->MarkTrace( aTrackSegment, &nb_segm, NULL, NULL, true );
PICKED_ITEMS_LIST itemsListPicker; PICKED_ITEMS_LIST itemsListPicker;
bool change = false; bool change = false;
......
...@@ -33,7 +33,7 @@ void PCB_EDIT_FRAME::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) ...@@ -33,7 +33,7 @@ void PCB_EDIT_FRAME::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
l1 = Route_Layer_TOP; l2 = Route_Layer_BOTTOM; l1 = Route_Layer_TOP; l2 = Route_Layer_BOTTOM;
pt_track = MarkTrace( GetBoard(), pt_segm, &nb_segm, NULL, NULL, true ); pt_track = GetBoard()->MarkTrace( pt_segm, &nb_segm, NULL, NULL, true );
if ( DC ) if ( DC )
DrawTraces( DrawPanel, DC, pt_track, nb_segm, GR_XOR ); DrawTraces( DrawPanel, DC, pt_track, nb_segm, GR_XOR );
...@@ -87,8 +87,8 @@ void PCB_EDIT_FRAME::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) ...@@ -87,8 +87,8 @@ void PCB_EDIT_FRAME::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
for( ; ii < nb_segm; pt_segm = pt_segm->Next(), ii++ ) for( ; ii < nb_segm; pt_segm = pt_segm->Next(), ii++ )
{ {
pt_segm->start = Locate_Pad_Connecte( GetBoard(), pt_segm, START ); pt_segm->start = GetBoard()->GetPad( pt_segm, START );
pt_segm->end = Locate_Pad_Connecte( GetBoard(), pt_segm, END ); pt_segm->end = GetBoard()->GetPad( pt_segm, END );
} }
test_1_net_connexion( DC, pt_track->GetNet() ); test_1_net_connexion( DC, pt_track->GetNet() );
...@@ -113,7 +113,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) ...@@ -113,7 +113,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
} }
/* Avoid more than one via on the current location: */ /* Avoid more than one via on the current location: */
if( Locate_Via( GetBoard(), g_CurrentTrackSegment->m_End, g_CurrentTrackSegment->GetLayer() ) ) if( GetBoard()->GetVia( g_CurrentTrackSegment->m_End, g_CurrentTrackSegment->GetLayer() ) )
return false; return false;
for( TRACK* segm = g_FirstTrackSegment; segm; segm = segm->Next() ) for( TRACK* segm = g_FirstTrackSegment; segm; segm = segm->Next() )
...@@ -277,7 +277,7 @@ void PCB_EDIT_FRAME::DisplayNetStatus( wxDC* DC ) ...@@ -277,7 +277,7 @@ void PCB_EDIT_FRAME::DisplayNetStatus( wxDC* DC )
int layerMask = (1 << getActiveLayer()); int layerMask = (1 << getActiveLayer());
wxPoint pos = GetScreen()->RefPos( true ); wxPoint pos = GetScreen()->RefPos( true );
pt_segm = GetTrace( GetBoard(), GetBoard()->m_Track, pos, layerMask ); pt_segm = GetBoard()->GetTrace( pos, layerMask );
if( pt_segm == NULL ) if( pt_segm == NULL )
GetBoard()->DisplayInfo( this ); GetBoard()->DisplayInfo( this );
......
...@@ -104,7 +104,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) ...@@ -104,7 +104,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC )
GetBoard()->SetHightLightNet(0); GetBoard()->SetHightLightNet(0);
// Search for a starting point of the new track, a track or pad // Search for a starting point of the new track, a track or pad
LockPoint = LocateLockPoint( GetBoard(), pos, layerMask ); LockPoint = GetBoard()->GetLockPoint( pos, layerMask );
if( LockPoint ) // An item (pad or track) is found if( LockPoint ) // An item (pad or track) is found
{ {
...@@ -120,7 +120,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) ...@@ -120,7 +120,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC )
{ {
TrackOnStartPoint = (TRACK*) LockPoint; TrackOnStartPoint = (TRACK*) LockPoint;
GetBoard()->SetHightLightNet( TrackOnStartPoint->GetNet() ); GetBoard()->SetHightLightNet( TrackOnStartPoint->GetNet() );
CreateLockPoint( GetBoard(), pos, TrackOnStartPoint, &s_ItemsListPicker ); GetBoard()->CreateLockPoint( pos, TrackOnStartPoint, &s_ItemsListPicker );
} }
} }
else // no starting point, but a filled zone area can exist. This is else // no starting point, but a filled zone area can exist. This is
...@@ -247,7 +247,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) ...@@ -247,7 +247,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC )
newTrack->SetState( BEGIN_ONPAD | END_ONPAD, OFF ); newTrack->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
oneBeforeLatest->end = Locate_Pad_Connecte( GetBoard(), oneBeforeLatest, END ); oneBeforeLatest->end = GetBoard()->GetPad( oneBeforeLatest, END );
if( oneBeforeLatest->end ) if( oneBeforeLatest->end )
{ {
...@@ -451,7 +451,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* DC ) ...@@ -451,7 +451,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* DC )
* This helps to reduce the computing time */ * This helps to reduce the computing time */
/* Attaching the end of the track. */ /* Attaching the end of the track. */
BOARD_ITEM* LockPoint = LocateLockPoint( GetBoard(), pos, layerMask ); BOARD_ITEM* LockPoint = GetBoard()->GetLockPoint( pos, layerMask );
if( LockPoint ) /* End of trace is on a pad. */ if( LockPoint ) /* End of trace is on a pad. */
{ {
...@@ -466,10 +466,9 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* DC ) ...@@ -466,10 +466,9 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* DC )
GetBoard()->SetHightLightNet( adr_buf->GetNet() ); GetBoard()->SetHightLightNet( adr_buf->GetNet() );
/* Possible establishment of a hanging point. */ /* Possible establishment of a hanging point. */
LockPoint = CreateLockPoint( GetBoard(), LockPoint = GetBoard()->CreateLockPoint( g_CurrentTrackSegment->m_End,
g_CurrentTrackSegment->m_End, adr_buf,
adr_buf, &s_ItemsListPicker );
&s_ItemsListPicker );
} }
} }
...@@ -1050,7 +1049,7 @@ void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList ) ...@@ -1050,7 +1049,7 @@ void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList )
while( track != NULL ) while( track != NULL )
{ {
TRACK* next_track = track->Next(); TRACK* next_track = track->Next();
LockPoint = Locate_Pad_Connecte( pcb, track, END ); LockPoint = pcb->GetPad( track, END );
if( LockPoint ) if( LockPoint )
{ {
......
...@@ -555,7 +555,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit ...@@ -555,7 +555,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
if( !itemCurrentlyEdited ) if( !itemCurrentlyEdited )
{ {
pos = screen->RefPos( true ); pos = screen->RefPos( true );
module = Locate_Prefered_Module( GetBoard(), pos, screen->m_Active_Layer, true ); module = GetBoard()->GetModule( pos, screen->m_Active_Layer, true );
} }
else if( GetCurItem()->Type() == TYPE_MODULE ) else if( GetCurItem()->Type() == TYPE_MODULE )
{ {
...@@ -641,7 +641,7 @@ bool PCB_EDIT_FRAME::OnHotkeyDeleteItem( wxDC* aDC ) ...@@ -641,7 +641,7 @@ bool PCB_EDIT_FRAME::OnHotkeyDeleteItem( wxDC* aDC )
if( ItemFree ) if( ItemFree )
{ {
wxPoint pos = GetScreen()->RefPos( false ); wxPoint pos = GetScreen()->RefPos( false );
MODULE* module = Locate_Prefered_Module( GetBoard(), pos, ALL_LAYERS, false ); MODULE* module = GetBoard()->GetModule( pos, ALL_LAYERS, false );
if( module == NULL ) if( module == NULL )
return false; return false;
...@@ -659,14 +659,19 @@ bool PCB_EDIT_FRAME::OnHotkeyDeleteItem( wxDC* aDC ) ...@@ -659,14 +659,19 @@ bool PCB_EDIT_FRAME::OnHotkeyDeleteItem( wxDC* aDC )
if( ItemFree ) if( ItemFree )
{ {
item = PcbGeneralLocateAndDisplay(); item = PcbGeneralLocateAndDisplay();
if( item == NULL ) if( item == NULL )
return false; return false;
if( (item->Type() == TYPE_MODULE) && !IsOK( this, _( "Delete module?" ) ) ) if( (item->Type() == TYPE_MODULE) && !IsOK( this, _( "Delete module?" ) ) )
return false; return false;
RemoveStruct( item, aDC ); RemoveStruct( item, aDC );
} }
else else
return false; {
return false;
}
} }
OnModify(); OnModify();
......
...@@ -40,7 +40,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery ) ...@@ -40,7 +40,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
// delete the old BOARD and create a new BOARD so that the default // delete the old BOARD and create a new BOARD so that the default
// layer names are put into the BOARD. // layer names are put into the BOARD.
SetBoard( new BOARD( NULL, this ) ); SetBoard( new BOARD( NULL ) );
SetCurItem( NULL ); SetCurItem( NULL );
/* clear filename, to avoid overwriting an old file */ /* clear filename, to avoid overwriting an old file */
......
This diff is collapsed.
...@@ -153,7 +153,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr ...@@ -153,7 +153,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr
if( doPad ) if( doPad )
{ {
int layer_mask = g_TabOneLayerMask[screen->m_Active_Layer]; int layer_mask = g_TabOneLayerMask[screen->m_Active_Layer];
D_PAD* pad = Locate_Any_Pad( m_Pcb, pos, layer_mask ); D_PAD* pad = m_Pcb->GetPad( pos, layer_mask );
if( pad ) if( pad )
{ {
...@@ -171,7 +171,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr ...@@ -171,7 +171,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr
int layer = screen->m_Active_Layer; int layer = screen->m_Active_Layer;
for( TRACK* via = m_Pcb->m_Track; for( TRACK* via = m_Pcb->m_Track;
via && (via = Locate_Via_Area( via, *curpos, layer )) != NULL; via && (via = via->GetVia( *curpos, layer )) != NULL;
via = via->Next() ) via = via->Next() )
{ {
if( via != currTrack ) // a via cannot influence itself if( via != currTrack ) // a via cannot influence itself
...@@ -193,7 +193,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr ...@@ -193,7 +193,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr
{ {
int layer_mask = g_TabOneLayerMask[layer]; int layer_mask = g_TabOneLayerMask[layer];
TRACK* track = GetTrace( m_Pcb, m_Pcb->m_Track, pos, layer_mask ); TRACK* track = m_Pcb->m_Track->GetTrace( pos, layer_mask );
if( !track || track->Type() != TYPE_TRACK ) if( !track || track->Type() != TYPE_TRACK )
{ {
......
...@@ -127,10 +127,9 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( wxWindow* father, ...@@ -127,10 +127,9 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( wxWindow* father,
UpdateTitle(); UpdateTitle();
if( g_ModuleEditor_Pcb == NULL ) if( g_ModuleEditor_Pcb == NULL )
g_ModuleEditor_Pcb = new BOARD( NULL, this ); g_ModuleEditor_Pcb = new BOARD( NULL );
SetBoard( g_ModuleEditor_Pcb ); SetBoard( g_ModuleEditor_Pcb );
GetBoard()->m_PcbFrame = this;
if( s_screenModule == NULL ) if( s_screenModule == NULL )
s_screenModule = new PCB_SCREEN(); s_screenModule = new PCB_SCREEN();
......
...@@ -1019,14 +1019,15 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) ...@@ -1019,14 +1019,15 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC )
* (only pad connection must be tested, track connection will be * (only pad connection must be tested, track connection will be
* tested by test_1_net_connexion() ) */ * tested by test_1_net_connexion() ) */
int layerMask = g_TabOneLayerMask[Track->GetLayer()]; int layerMask = g_TabOneLayerMask[Track->GetLayer()];
Track->start = Fast_Locate_Pad_Connecte( GetBoard(), Track->m_Start, layerMask ); Track->start = GetBoard()->GetPadFast( Track->m_Start, layerMask );
if( Track->start ) if( Track->start )
Track->SetState( BEGIN_ONPAD, ON ); Track->SetState( BEGIN_ONPAD, ON );
else else
Track->SetState( BEGIN_ONPAD, OFF ); Track->SetState( BEGIN_ONPAD, OFF );
Track->end = Fast_Locate_Pad_Connecte( GetBoard(), Track->m_End, layerMask ); Track->end = GetBoard()->GetPadFast( Track->m_End, layerMask );
if( Track->end ) if( Track->end )
Track->SetState( END_ONPAD, ON ); Track->SetState( END_ONPAD, ON );
else else
...@@ -1054,147 +1055,3 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) ...@@ -1054,147 +1055,3 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC )
return true; return true;
} }
/* Find the point "attachment" of the end of a trace.
* This may be a TBP or another segment of the trace
* Returns:
* - Pointer to the PAD or:
* - Pointer to the segment or:
* - NULL
* Parameters:
* - position to test
* - mask layers to be tested
*/
BOARD_ITEM* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask )
{
for( MODULE* module = Pcb->m_Modules; module; module = module->Next() )
{
D_PAD* pad = Locate_Pads( module, pos, LayerMask );
if( pad )
return pad;
}
/* No pad has been located so check for a segment of the trace. */
TRACK* ptsegm = GetTrace( Pcb->m_Track, NULL, pos, LayerMask );
if( ptsegm == NULL )
ptsegm = GetTrace( Pcb, Pcb->m_Track, pos, LayerMask );
return ptsegm;
}
/* Create an intermediate point on a segment
* aSegm segment is broken into 2 segments connecting point pX, pY
* After insertion:
* The new segment starts from to new point, and ends to initial aSegm ending point
* the old segment aSegm ends to new point
* Returns:
* NULL if no new point (ie if aRefPoint already corresponded at one end of aSegm
* or
* Pointer to the segment created
* Returns the exact value of aRefPoint
* If aSegm points to a via:
* Returns the exact value of aRefPoint and a pointer to the via,
* But does not create extra point
*/
TRACK* CreateLockPoint( BOARD* aPcb,
wxPoint& aRefPoint,
TRACK* aSegm,
PICKED_ITEMS_LIST* aItemsListPicker )
{
if( aSegm->m_Start == aRefPoint || aSegm->m_End == aRefPoint )
return NULL;
/* A via is a good lock point */
if( aSegm->Type() == TYPE_VIA )
{
aRefPoint = aSegm->m_Start;
return aSegm;
}
/* Calculation coordinate of intermediate point relative to
* the start point of aSegm
*/
wxPoint delta = aSegm->m_End - aSegm->m_Start;
// Not yet in use:
#if 0
int ox, oy, fx, fy;
if( aRefSegm )
{
ox = aRefSegm->m_Start.x - aSegm->m_Start.x;
oy = aRefSegm->m_Start.y - aSegm->m_Start.y;
fx = aRefSegm->m_End.x - aSegm->m_Start.x;
fy = aRefSegm->m_End.y - aSegm->m_Start.y;
}
#endif
// calculate coordinates of aRefPoint relative to aSegm->m_Start
wxPoint newPoint = aRefPoint - aSegm->m_Start;
// newPoint must be on aSegm:
// Ensure newPoint.y/newPoint.y = delta.y/delta.x
if( delta.x == 0 )
newPoint.x = 0; /* horizontal segment*/
else
newPoint.y = wxRound(( (double)newPoint.x * delta.y ) / delta.x);
/* Create the intermediate point (that is to say creation of a new
* segment, beginning at the intermediate point.
*/
newPoint.x += aSegm->m_Start.x;
newPoint.y += aSegm->m_Start.y;
TRACK* newTrack = aSegm->Copy();
if( aItemsListPicker )
{
ITEM_PICKER picker( newTrack, UR_NEW );
aItemsListPicker->PushItem( picker );
}
DLIST<TRACK>* list = (DLIST<TRACK>*)aSegm->GetList();
wxASSERT( list );
list->Insert( newTrack, aSegm->Next() );
if( aItemsListPicker )
{
ITEM_PICKER picker( aSegm, UR_CHANGED );
picker.m_Link = aSegm->Copy();
aItemsListPicker->PushItem( picker );
}
/* Correct pointer at the end of the new segment. */
newTrack->end = aSegm->end;
newTrack->SetState( END_ONPAD, aSegm->GetState( END_ONPAD ) );
/* Set connections info relative to the new point
*/
/* Old segment now ends at new point. */
aSegm->m_End = newPoint;
aSegm->end = newTrack;
aSegm->SetState( END_ONPAD, OFF );
/* The new segment begins at the new point. */
newTrack->m_Start = newPoint;
newTrack->start = aSegm;
newTrack->SetState( BEGIN_ONPAD, OFF );
D_PAD * pad = Locate_Pad_Connecte( aPcb, newTrack, START );
if ( pad )
{
newTrack->start = pad;
newTrack->SetState( BEGIN_ONPAD, ON );
aSegm->end = pad;
aSegm->SetState( END_ONPAD, ON );
}
aRefPoint = newPoint;
return newTrack;
}
...@@ -48,7 +48,8 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) ...@@ -48,7 +48,8 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
{ {
if( item && item->m_Flags ) if( item && item->m_Flags )
{ {
AddMenuItem( aPopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ), KiBitmap( cancel_xpm ) ); AddMenuItem( aPopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ),
KiBitmap( cancel_xpm ) );
} }
else else
{ {
...@@ -166,7 +167,8 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) ...@@ -166,7 +167,8 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
HK_MOVE_ITEM ); HK_MOVE_ITEM );
AddMenuItem( aPopMenu, ID_POPUP_PCB_MOVE_DRAWING_REQUEST, AddMenuItem( aPopMenu, ID_POPUP_PCB_MOVE_DRAWING_REQUEST,
msg, KiBitmap( move_xpm ) ); msg, KiBitmap( move_xpm ) );
AddMenuItem( aPopMenu, ID_POPUP_PCB_EDIT_DRAWING, _( "Edit Drawing" ), KiBitmap( edit_xpm ) ); AddMenuItem( aPopMenu, ID_POPUP_PCB_EDIT_DRAWING, _( "Edit Drawing" ),
KiBitmap( edit_xpm ) );
AddMenuItem( aPopMenu, ID_POPUP_PCB_DELETE_DRAWING, AddMenuItem( aPopMenu, ID_POPUP_PCB_DELETE_DRAWING,
_( "Delete Drawing" ), KiBitmap( delete_xpm ) ); _( "Delete Drawing" ), KiBitmap( delete_xpm ) );
...@@ -293,7 +295,8 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) ...@@ -293,7 +295,8 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
case ID_TRACK_BUTT: case ID_TRACK_BUTT:
if ( ! locate_track ) // This menu is already added when a track is located if ( ! locate_track ) // This menu is already added when a track is located
AddMenuItem( aPopMenu, Append_Track_Width_List( GetBoard() ), AddMenuItem( aPopMenu, Append_Track_Width_List( GetBoard() ),
ID_POPUP_PCB_SELECT_WIDTH, _( "Select Track Width" ), KiBitmap( width_track_xpm ) ); ID_POPUP_PCB_SELECT_WIDTH, _( "Select Track Width" ),
KiBitmap( width_track_xpm ) );
AddMenuItem( aPopMenu, ID_POPUP_PCB_SELECT_CU_LAYER, AddMenuItem( aPopMenu, ID_POPUP_PCB_SELECT_CU_LAYER,
_( "Select Working Layer" ), KiBitmap( select_w_layer_xpm ) ); _( "Select Working Layer" ), KiBitmap( select_w_layer_xpm ) );
...@@ -375,7 +378,8 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) ...@@ -375,7 +378,8 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
*/ */
void PCB_EDIT_FRAME::createPopUpBlockMenu( wxMenu* menu ) void PCB_EDIT_FRAME::createPopUpBlockMenu( wxMenu* menu )
{ {
AddMenuItem( menu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ), KiBitmap( cancel_xpm ) ); AddMenuItem( menu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ),
KiBitmap( cancel_xpm ) );
AddMenuItem( menu, ID_POPUP_ZOOM_BLOCK, _( "Zoom Block" ), KiBitmap( zoom_area_xpm ) ); AddMenuItem( menu, ID_POPUP_ZOOM_BLOCK, _( "Zoom Block" ), KiBitmap( zoom_area_xpm ) );
menu->AppendSeparator(); menu->AppendSeparator();
AddMenuItem( menu, ID_POPUP_PLACE_BLOCK, _( "Place Block" ), KiBitmap( apply_xpm ) ); AddMenuItem( menu, ID_POPUP_PLACE_BLOCK, _( "Place Block" ), KiBitmap( apply_xpm ) );
...@@ -404,7 +408,8 @@ void PCB_EDIT_FRAME::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) ...@@ -404,7 +408,8 @@ void PCB_EDIT_FRAME::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu )
{ {
if( Track->Type() == TYPE_VIA ) if( Track->Type() == TYPE_VIA )
{ {
AddMenuItem( PopMenu, ID_POPUP_PCB_MOVE_TRACK_NODE, _( "Drag Via" ), KiBitmap( move_xpm ) ); AddMenuItem( PopMenu, ID_POPUP_PCB_MOVE_TRACK_NODE, _( "Drag Via" ),
KiBitmap( move_xpm ) );
} }
else else
{ {
...@@ -485,10 +490,10 @@ void PCB_EDIT_FRAME::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) ...@@ -485,10 +490,10 @@ void PCB_EDIT_FRAME::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu )
// Delete control: // Delete control:
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
wxMenu* track_mnu = new wxMenu; wxMenu* track_mnu = new wxMenu;
AddMenuItem( PopMenu, track_mnu, ID_POPUP_PCB_DELETE_TRACK_MNU, _( "Delete" ), KiBitmap( delete_xpm ) ); AddMenuItem( PopMenu, track_mnu, ID_POPUP_PCB_DELETE_TRACK_MNU, _( "Delete" ),
KiBitmap( delete_xpm ) );
msg = AddHotkeyName( Track->Type()==TYPE_VIA ? msg = AddHotkeyName( Track->Type()==TYPE_VIA ? _( "Delete Via" ) : _( "Delete Segment" ),
_( "Delete Via" ) : _( "Delete Segment" ),
g_Board_Editor_Hokeys_Descr, HK_BACK_SPACE ); g_Board_Editor_Hokeys_Descr, HK_BACK_SPACE );
AddMenuItem( track_mnu, ID_POPUP_PCB_DELETE_TRACKSEG, msg, KiBitmap( delete_line_xpm ) ); AddMenuItem( track_mnu, ID_POPUP_PCB_DELETE_TRACKSEG, msg, KiBitmap( delete_line_xpm ) );
...@@ -497,7 +502,8 @@ void PCB_EDIT_FRAME::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) ...@@ -497,7 +502,8 @@ void PCB_EDIT_FRAME::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu )
{ {
msg = AddHotkeyName( _( "Delete Track" ), g_Board_Editor_Hokeys_Descr, HK_DELETE ); msg = AddHotkeyName( _( "Delete Track" ), g_Board_Editor_Hokeys_Descr, HK_DELETE );
AddMenuItem( track_mnu, ID_POPUP_PCB_DELETE_TRACK, msg, KiBitmap( delete_track_xpm ) ); AddMenuItem( track_mnu, ID_POPUP_PCB_DELETE_TRACK, msg, KiBitmap( delete_track_xpm ) );
AddMenuItem( track_mnu, ID_POPUP_PCB_DELETE_TRACKNET, _( "Delete Net" ), KiBitmap( delete_net_xpm ) ); AddMenuItem( track_mnu, ID_POPUP_PCB_DELETE_TRACKNET, _( "Delete Net" ),
KiBitmap( delete_net_xpm ) );
} }
// Add global edition command // Add global edition command
...@@ -511,7 +517,8 @@ void PCB_EDIT_FRAME::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) ...@@ -511,7 +517,8 @@ void PCB_EDIT_FRAME::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu )
// Add lock/unlock flags menu: // Add lock/unlock flags menu:
track_mnu = new wxMenu; track_mnu = new wxMenu;
AddMenuItem( PopMenu, track_mnu, ID_POPUP_PCB_SETFLAGS_TRACK_MNU, _( "Set Flags" ), KiBitmap( flag_xpm ) ); AddMenuItem( PopMenu, track_mnu, ID_POPUP_PCB_SETFLAGS_TRACK_MNU, _( "Set Flags" ),
KiBitmap( flag_xpm ) );
track_mnu->Append( ID_POPUP_PCB_LOCK_ON_TRACKSEG, _( "Locked: Yes" ), wxEmptyString, true ); track_mnu->Append( ID_POPUP_PCB_LOCK_ON_TRACKSEG, _( "Locked: Yes" ), wxEmptyString, true );
track_mnu->Append( ID_POPUP_PCB_LOCK_OFF_TRACKSEG, _( "Locked: No" ), wxEmptyString, true ); track_mnu->Append( ID_POPUP_PCB_LOCK_OFF_TRACKSEG, _( "Locked: No" ), wxEmptyString, true );
...@@ -557,14 +564,19 @@ void PCB_EDIT_FRAME::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* ...@@ -557,14 +564,19 @@ void PCB_EDIT_FRAME::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu*
AddMenuItem( aPopMenu, zones_menu, -1, _( "Zones" ), KiBitmap( add_zone_xpm ) ); AddMenuItem( aPopMenu, zones_menu, -1, _( "Zones" ), KiBitmap( add_zone_xpm ) );
if( edge_zone->HitTestForCorner( GetScreen()->RefPos( true ) ) ) // Use grid size because it is known
wxRealPoint grid = DrawPanel->GetGrid();
if( edge_zone->HitTestForCorner( GetScreen()->RefPos( true ),
wxRound( MIN( grid.x, grid.y ) ) ) )
{ {
AddMenuItem( zones_menu, ID_POPUP_PCB_MOVE_ZONE_CORNER, AddMenuItem( zones_menu, ID_POPUP_PCB_MOVE_ZONE_CORNER,
_( "Move Corner" ), KiBitmap( move_xpm ) ); _( "Move Corner" ), KiBitmap( move_xpm ) );
AddMenuItem( zones_menu, ID_POPUP_PCB_DELETE_ZONE_CORNER, AddMenuItem( zones_menu, ID_POPUP_PCB_DELETE_ZONE_CORNER,
_( "Delete Corner" ), KiBitmap( delete_xpm ) ); _( "Delete Corner" ), KiBitmap( delete_xpm ) );
} }
else if( edge_zone->HitTestForEdge( GetScreen()->RefPos( true ) ) ) else if( edge_zone->HitTestForEdge( GetScreen()->RefPos( true ),
wxRound( MIN( grid.x, grid.y ) ) ) )
{ {
AddMenuItem( zones_menu, ID_POPUP_PCB_ADD_ZONE_CORNER, AddMenuItem( zones_menu, ID_POPUP_PCB_ADD_ZONE_CORNER,
_( "Create Corner" ), KiBitmap( add_corner_xpm ) ); _( "Create Corner" ), KiBitmap( add_corner_xpm ) );
...@@ -582,7 +594,8 @@ void PCB_EDIT_FRAME::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* ...@@ -582,7 +594,8 @@ void PCB_EDIT_FRAME::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu*
_( "Add Cutout Area" ), KiBitmap( add_zone_cutout_xpm ) ); _( "Add Cutout Area" ), KiBitmap( add_zone_cutout_xpm ) );
zones_menu->AppendSeparator(); zones_menu->AppendSeparator();
AddMenuItem( zones_menu, ID_POPUP_PCB_FILL_ZONE, _( "Fill Zone" ), KiBitmap( fill_zone_xpm ) ); AddMenuItem( zones_menu, ID_POPUP_PCB_FILL_ZONE, _( "Fill Zone" ),
KiBitmap( fill_zone_xpm ) );
if( edge_zone->m_FilledPolysList.size() > 0 ) if( edge_zone->m_FilledPolysList.size() > 0 )
{ {
...@@ -645,7 +658,8 @@ void PCB_EDIT_FRAME::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* menu ...@@ -645,7 +658,8 @@ void PCB_EDIT_FRAME::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* menu
if( !flags ) if( !flags )
{ {
msg = AddHotkeyName( _( "Edit" ), g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); msg = AddHotkeyName( _( "Edit" ), g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_EDIT_MODULE, msg, KiBitmap( edit_module_xpm ) ); AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_EDIT_MODULE, msg,
KiBitmap( edit_module_xpm ) );
sub_menu_footprint->AppendSeparator(); sub_menu_footprint->AppendSeparator();
AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_DELETE_MODULE, AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_DELETE_MODULE,
_( "Delete Module" ), KiBitmap( delete_module_xpm ) ); _( "Delete Module" ), KiBitmap( delete_module_xpm ) );
...@@ -725,8 +739,10 @@ void PCB_EDIT_FRAME::createPopUpMenuForFpPads( D_PAD* Pad, wxMenu* menu ) ...@@ -725,8 +739,10 @@ void PCB_EDIT_FRAME::createPopUpMenuForFpPads( D_PAD* Pad, wxMenu* menu )
sub_menu_Pad = new wxMenu; sub_menu_Pad = new wxMenu;
AddMenuItem( menu, sub_menu_Pad, -1, msg, KiBitmap( pad_xpm ) ); AddMenuItem( menu, sub_menu_Pad, -1, msg, KiBitmap( pad_xpm ) );
AddMenuItem( sub_menu_Pad, ID_POPUP_PCB_MOVE_PAD_REQUEST, _( "Move" ), KiBitmap( move_pad_xpm ) ); AddMenuItem( sub_menu_Pad, ID_POPUP_PCB_MOVE_PAD_REQUEST, _( "Move" ),
AddMenuItem( sub_menu_Pad, ID_POPUP_PCB_DRAG_PAD_REQUEST, _( "Drag" ), KiBitmap( drag_pad_xpm ) ); KiBitmap( move_pad_xpm ) );
AddMenuItem( sub_menu_Pad, ID_POPUP_PCB_DRAG_PAD_REQUEST, _( "Drag" ),
KiBitmap( drag_pad_xpm ) );
AddMenuItem( sub_menu_Pad, ID_POPUP_PCB_EDIT_PAD, _( "Edit" ), KiBitmap( options_pad_xpm ) ); AddMenuItem( sub_menu_Pad, ID_POPUP_PCB_EDIT_PAD, _( "Edit" ), KiBitmap( options_pad_xpm ) );
sub_menu_Pad->AppendSeparator(); sub_menu_Pad->AppendSeparator();
...@@ -790,14 +806,17 @@ void PCB_EDIT_FRAME::createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu ) ...@@ -790,14 +806,17 @@ void PCB_EDIT_FRAME::createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu )
_( "Reset Size" ), KiBitmap( reset_text_xpm ) ); _( "Reset Size" ), KiBitmap( reset_text_xpm ) );
sub_menu_Text->AppendSeparator(); sub_menu_Text->AppendSeparator();
AddMenuItem( sub_menu_Text, ID_POPUP_PCB_DELETE_TEXTEPCB, _( "Delete" ), KiBitmap( delete_text_xpm ) ); AddMenuItem( sub_menu_Text, ID_POPUP_PCB_DELETE_TEXTEPCB, _( "Delete" ),
KiBitmap( delete_text_xpm ) );
} }
void PCB_EDIT_FRAME::createPopUpMenuForMarkers( MARKER_PCB* aMarker, wxMenu* aPopMenu ) void PCB_EDIT_FRAME::createPopUpMenuForMarkers( MARKER_PCB* aMarker, wxMenu* aPopMenu )
{ {
AddMenuItem( aPopMenu, ID_POPUP_PCB_DELETE_MARKER, _( "Delete Marker" ), KiBitmap( delete_xpm ) ); AddMenuItem( aPopMenu, ID_POPUP_PCB_DELETE_MARKER, _( "Delete Marker" ),
AddMenuItem( aPopMenu, ID_POPUP_PCB_GETINFO_MARKER, _( "Marker Error Info" ), KiBitmap( info_xpm ) ); KiBitmap( delete_xpm ) );
AddMenuItem( aPopMenu, ID_POPUP_PCB_GETINFO_MARKER, _( "Marker Error Info" ),
KiBitmap( info_xpm ) );
} }
......
...@@ -277,10 +277,11 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, ...@@ -277,10 +277,11 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
m_HotkeysZoomAndGridList = g_Board_Editor_Hokeys_Descr; m_HotkeysZoomAndGridList = g_Board_Editor_Hokeys_Descr;
m_RecordingMacros = -1; m_RecordingMacros = -1;
for ( int i = 0; i < 10; i++ ) for ( int i = 0; i < 10; i++ )
m_Macros[i].m_Record.clear(); m_Macros[i].m_Record.clear();
SetBoard( new BOARD( NULL, this ) ); SetBoard( new BOARD( NULL ) );
// Create the PCB_LAYER_WIDGET *after* SetBoard(): // Create the PCB_LAYER_WIDGET *after* SetBoard():
...@@ -417,6 +418,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, ...@@ -417,6 +418,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
PCB_EDIT_FRAME::~PCB_EDIT_FRAME() PCB_EDIT_FRAME::~PCB_EDIT_FRAME()
{ {
m_RecordingMacros = -1; m_RecordingMacros = -1;
for( int i = 0; i < 10; i++ ) for( int i = 0; i < 10; i++ )
m_Macros[i].m_Record.clear(); m_Macros[i].m_Record.clear();
......
/***********/ /**
/* protos.h */ * @file pcbnew/protos.h
/***********/ */
#ifndef PROTO_H #ifndef PROTO_H
#define PROTO_H #define PROTO_H
#include <vector>
class COMMAND;
/** /**
* Function SwapData * Function SwapData
* Used in undo / redo command: * Used in undo / redo command:
...@@ -22,24 +17,6 @@ class COMMAND; ...@@ -22,24 +17,6 @@ class COMMAND;
void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ); void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage );
/*******************/
/* PAD_CONNECT.CPP */
/*******************/
class D_PAD;
/**
* Function CreateSortedPadListByXCoord
* first empties then fills the vector with all pads and sorts them by
* increasing x coordinate. The vector only holds pointers to the pads and
* those pointers are only references to pads which are owned by the BOARD
* through other links.
* @param aBoard Which board to gather pads from.
* @param aVector Where to put the pad pointers.
*/
void CreateSortedPadListByXCoord( BOARD* aBoard, std::vector<D_PAD*>* aVector );
/***************/ /***************/
/* TRPISTE.CPP */ /* TRPISTE.CPP */
/***************/ /***************/
...@@ -66,31 +43,6 @@ void DrawTraces( EDA_DRAW_PANEL* panel, ...@@ -66,31 +43,6 @@ void DrawTraces( EDA_DRAW_PANEL* panel,
/* LOCATE.CPP : */ /* LOCATE.CPP : */
/****************/ /****************/
/* Find a pad by it's name om the module. */
TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer = -1 );
/**
* Function Locate_Via_Area
* finds the first SEGVIA which covers the given aPos with a matching layer.
* @param aStart The starting TRACK or SEGVIA in the BOARD's list.
* @param aPos The wxPoint to HitTest() against.
* @param aLayer The layer to match, pass -1 for a don't care.
* @return TRACK* - actually a SEGVIA* if found, else NULL.
*/
TRACK* Locate_Via_Area( TRACK* aStart, const wxPoint& aPos, int aLayer = ALL_LAYERS );
/* Locates the center through the point x, y, on layer data
* by masquelayer.
* Search is done to address start_adr has end_adr (not included)
*/
TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr, const wxPoint& pos, int masquelayer );
/* Locates the center through the point x, y, on layer data
* by masquelayer.
* Search is done to address start_adr has end_adr (not included)
*/
TRACK* GetTrace( TRACK* start_adr, TRACK* end_adr, const wxPoint& ref_pos, int masquelayer );
/* Search for segment connected to the segment edge by /* Search for segment connected to the segment edge by
* Ptr_piste: * Ptr_piste:
* If int = START, the point of beginning of the segment is used * If int = START, the point of beginning of the segment is used
...@@ -100,86 +52,6 @@ TRACK* GetTrace( TRACK* start_adr, TRACK* end_adr, const wxPoint& ref_pos, int m ...@@ -100,86 +52,6 @@ TRACK* GetTrace( TRACK* start_adr, TRACK* end_adr, const wxPoint& ref_pos, int m
*/ */
TRACK* GetConnectedTrace( TRACK* aTrace, TRACK* pt_base, TRACK* pt_lim, int extr ); TRACK* GetConnectedTrace( TRACK* aTrace, TRACK* pt_base, TRACK* pt_lim, int extr );
/*
* 1 - Locate segment of track leading from the mouse.
* 2 - Locate segment of track point by point.
* Ref_pX, ref_pY.
*
* If layer <0 the layer is not tested.
*
* The search begins to address start_adresse
*/
TRACK* GetTrace( BOARD* aPcb, TRACK* start_adresse, const wxPoint& ref_pos, int layer );
/* Locate pad connected to the beginning or end of a segment
* Input: pointer to the segment, and flag = START or END
* Returns:
* A pointer to the description of the patch if pad was found.
* NULL pointer if pad was not found.
*/
D_PAD* Locate_Pad_Connecte( BOARD* aPcb, TRACK* ptr_segment, int extr );
/*
* Locate pad pointed to by the coordinate ref_pX,, ref_pY or the current
* cursor position, search done on all tracks.
* Entry:
* - Mouse coord (Curseur_X and Curseur_Y)
* Or ref_pX, ref_pY
* Returns:
* Pointer to the pad if found
* NULL pointer if pad not found
*/
D_PAD* Locate_Any_Pad( BOARD* aPcb, const wxPoint& aPosition, int aLayerMask = ALL_LAYERS );
/* Locate pad pointed to by the coordinate ref_pX,, ref_pY or the cursor
* position of the current footprint.
* Input:
* - The module to search.
* - Layer to search or -1 to search all layers.
* Returns:
* A pointer to the pad if found otherwise NULL.
*/
D_PAD* Locate_Pads( MODULE* Module, const wxPoint& ref_pos, int layer );
/* Locate a footprint by its bounding rectangle. */
MODULE* Locate_Prefered_Module( BOARD* aPcb, const wxPoint& aPosition, int aActiveLayer,
bool aVisibleOnly, bool aIgnoreLocked = false );
/* Locate a pad pointed to by the cursor on the footprint.
* Module.
* Input:
* - Module to search.
* Returns:
* A pointer to the pad if found otherwise NULL.
*/
D_PAD* Locate_Pads( MODULE* Module, int typeloc );
/* Locate a trace segment at the current cursor position.
* The search begins to address start_adresse.
*/
TRACK* GetTrace( TRACK* start_adresse, int typeloc );
DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc );
/* Locate pad containing the point px, py, layer on layer.
*
* The list of pads must already exist.
*
* Returns:
* Pointer to the pad if found, otherwise NULL.
*/
D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int layer );
/*
* 1 - Locate trace segment at the current cursor position.
* 2 - Locate trace segment at the given coordinates ref_pos.
*
* If layer == -1, check all layers.
*
* The search begins to address start_adresse
*/
TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int layer );
/*************/ /*************/
/* MODULES.C */ /* MODULES.C */
...@@ -204,84 +76,9 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo ...@@ -204,84 +76,9 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
void CalculateSegmentEndPoint( const wxPoint& aPosition, int ox, int oy, int* fx, int* fy ); void CalculateSegmentEndPoint( const wxPoint& aPosition, int ox, int oy, int* fx, int* fy );
/*****************/
/* TRACK.CPP : */
/*****************/
/**
* Function MarkTrace
* marks a chain of track segments, connected to aTrackList.
* Each segment is marked by setting the BUSY bit into m_Flags. Electrical
* continuity is detected by walking each segment, and finally the segments
* are rearranged into a contiguous chain within the given list.
*
* @param aPcb = the board to analyze
* @param aStartSegm - The first interesting segment within a list of track
* segment of aPcb
* @param aSegmCount = a pointer to an integer where to return the number of
* interesting segments
* @param aTrackLen = a pointer to an integer where to return the lenght of the
* track
* @param aLengthDie = a pointer to an integer where to return the extra lengths inside
* integrated circuits from the pads connected to this track to the
* die (if any)
* @param aReorder = true for reorder the interesting segments (useful for
* track edition/deletion) in this case the flag BUSY is
* set (the user is responsible of flag clearing). False
* for no reorder : useful when we want just calculate the
* track length in this case, flags are reset
* @return TRACK* the first in the chain of interesting segments.
*/
TRACK* MarkTrace( BOARD* aPcb,
TRACK* aStartSegm,
int* aSegmCount,
int* aTrackLen,
int* aLengthDie,
bool aReorder );
/* Calculate end coordinate of a trace.
* Returns 1 if OK, 0 if trace looped back on itself.
* The coord are returned StartTrack-> ox, oy
* And EndTrack-> fx, fy if OK
* The segments are drawn consecutively.
*/
int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, TRACK** StartTrack, TRACK** EndTrack );
/***************/ /***************/
/***************/ /***************/
/* Routine to find the point "attachment" at the end of a trace.
* This may be a PAD or another trace segment.
* Returns:
* - Pointer to the PAD or:
* - Pointer to the segment or:
* - NULL
* Parameters:
* - aPos - coordinate point test
* ALayerMask of mask layers to be tested
*/
BOARD_ITEM* LocateLockPoint( BOARD* aPcb, wxPoint aPos, int aLayerMask );
/* Create an intermediate point on a segment
* aSegm segment is broken into 2 segments connecting point pX, pY
* After insertion:
* The new segment starts from to new point, and ends to initial aSegm ending point
* the old segment aSegm ends to new point
* Returns:
* NULL if no new point (ie if aRefPoint already corresponded at one end of aSegm
* or
* Pointer to the segment created
* Returns the exact value of aRefPoint
* If aSegm points to a via:
* Returns the exact value of aRefPoint and a pointer to the via,
* But does not create extra point
*/
TRACK* CreateLockPoint( BOARD* aPcb,
wxPoint& aRefPoint,
TRACK* aSegm,
PICKED_ITEMS_LIST* aItemsListPicker );
/****************/ /****************/
/* CONTROLE.CPP */ /* CONTROLE.CPP */
......
...@@ -1268,14 +1268,12 @@ static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC ) ...@@ -1268,14 +1268,12 @@ static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
g_CurrentTrackList.PushBack( newTrack ); g_CurrentTrackList.PushBack( newTrack );
} }
g_FirstTrackSegment->start = Locate_Pad_Connecte( pcbframe->GetBoard(), g_FirstTrackSegment->start = pcbframe->GetBoard()->GetPad( g_FirstTrackSegment, START );
g_FirstTrackSegment, START );
if( g_FirstTrackSegment->start ) if( g_FirstTrackSegment->start )
g_FirstTrackSegment->SetState( BEGIN_ONPAD, ON ); g_FirstTrackSegment->SetState( BEGIN_ONPAD, ON );
g_CurrentTrackSegment->end = Locate_Pad_Connecte( pcbframe->GetBoard(), g_CurrentTrackSegment->end = pcbframe->GetBoard()->GetPad( g_CurrentTrackSegment, END );
g_CurrentTrackSegment, END );
if( g_CurrentTrackSegment->end ) if( g_CurrentTrackSegment->end )
g_CurrentTrackSegment->SetState( END_ONPAD, ON ); g_CurrentTrackSegment->SetState( END_ONPAD, ON );
......
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
#include "protos.h" #include "protos.h"
static void ListSetState( EDA_ITEM* Start, int NbItem, int State, int onoff ); static void ListSetState( EDA_ITEM* Start, int NbItem, int State, int onoff );
extern int ReturnEndsTrack( TRACK* RefTrack, int NbSegm,
TRACK** StartTrack, TRACK** EndTrack );
/** /**
...@@ -54,7 +52,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, ...@@ -54,7 +52,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
if( aNewTrack->Type() == TYPE_VIA && ( aNewTrackSegmentsCount > 1 ) ) if( aNewTrack->Type() == TYPE_VIA && ( aNewTrackSegmentsCount > 1 ) )
aNewTrack = aNewTrack->Next(); aNewTrack = aNewTrack->Next();
aNewTrack = MarkTrace( GetBoard(), aNewTrack, &aNewTrackSegmentsCount, NULL, NULL, true ); aNewTrack = GetBoard()->MarkTrace( aNewTrack, &aNewTrackSegmentsCount, NULL, NULL, true );
wxASSERT( aNewTrack ); wxASSERT( aNewTrack );
#if 0 && defined(DEBUG) #if 0 && defined(DEBUG)
...@@ -92,7 +90,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, ...@@ -92,7 +90,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
break; break;
} }
if( ReturnEndsTrack( aNewTrack, aNewTrackSegmentsCount, &StartTrack, &EndTrack ) == 0 ) if( aNewTrack->GetEndSegments( aNewTrackSegmentsCount, &StartTrack, &EndTrack ) == 0 )
return 0; return 0;
if( ( StartTrack == NULL ) || ( EndTrack == NULL ) ) if( ( StartTrack == NULL ) || ( EndTrack == NULL ) )
...@@ -110,7 +108,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, ...@@ -110,7 +108,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
endmasklayer = EndTrack->ReturnMaskLayer(); endmasklayer = EndTrack->ReturnMaskLayer();
/* There may be a via or a pad on the end points. */ /* There may be a via or a pad on the end points. */
pt_segm = Fast_Locate_Via( m_Pcb->m_Track, NULL, start, startmasklayer ); pt_segm = m_Pcb->m_Track->GetVia( NULL, start, startmasklayer );
if( pt_segm ) if( pt_segm )
startmasklayer |= pt_segm->ReturnMaskLayer(); startmasklayer |= pt_segm->ReturnMaskLayer();
...@@ -122,7 +120,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, ...@@ -122,7 +120,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
startmasklayer |= pt_pad->m_layerMask; startmasklayer |= pt_pad->m_layerMask;
} }
pt_segm = Fast_Locate_Via( m_Pcb->m_Track, NULL, end, endmasklayer ); pt_segm = m_Pcb->m_Track->GetVia( NULL, end, endmasklayer );
if( pt_segm ) if( pt_segm )
endmasklayer |= pt_segm->ReturnMaskLayer(); endmasklayer |= pt_segm->ReturnMaskLayer();
...@@ -141,7 +139,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, ...@@ -141,7 +139,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
/* A segment must be connected to the starting point, otherwise /* A segment must be connected to the starting point, otherwise
* it is unnecessary to analyze the other point * it is unnecessary to analyze the other point
*/ */
pt_segm = GetTrace( bufStart, bufEnd, start, startmasklayer ); pt_segm = GetTraceByEndPoint( bufStart, bufEnd, start, startmasklayer );
if( pt_segm == NULL ) /* Not connected to the track starting point. */ if( pt_segm == NULL ) /* Not connected to the track starting point. */
{ {
...@@ -156,7 +154,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, ...@@ -156,7 +154,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
*/ */
for( pt_del = bufStart, nbconnect = 0; ; ) for( pt_del = bufStart, nbconnect = 0; ; )
{ {
pt_segm = GetTrace( pt_del, bufEnd, end, endmasklayer ); pt_segm = GetTraceByEndPoint( pt_del, bufEnd, end, endmasklayer );
if( pt_segm == NULL ) if( pt_segm == NULL )
break; break;
...@@ -211,7 +209,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, ...@@ -211,7 +209,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
nbconnect--; nbconnect--;
pt_del->SetState( IS_LINKED, OFF ); pt_del->SetState( IS_LINKED, OFF );
pt_del = MarkTrace( GetBoard(), pt_del, &nb_segm, NULL, NULL, true ); pt_del = GetBoard()->MarkTrace( pt_del, &nb_segm, NULL, NULL, true );
/* Test if the marked track is redundant, i.e. if one of marked segments /* Test if the marked track is redundant, i.e. if one of marked segments
* is connected to the starting point of the new track. * is connected to the starting point of the new track.
......
This diff is collapsed.
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