Commit ae84ca2f authored by Wayne Stambaugh's avatar Wayne Stambaugh

PCBNew locate pad code refactoring and other minor fixes.

* Refactor pad locate code into the appropriate object.
* Dead code removal.
* Lots of coding style policy fixes.
parent 3d7c91af
/***********************************************************/
/* wxPcbStruct.h: */
/* Classes used in pcbnew, cvpcb and gerbview */
/***********************************************************/
/**
* @file wxBasePcbStruct.h
* @brief Classes used in pcbnew, cvpcb and gerbview.
*/
#ifndef WX_BASE_PCB_FRAME_H
#define WX_BASE_PCB_FRAME_H
......@@ -98,16 +98,12 @@ public:
// General
virtual void OnCloseWindow( wxCloseEvent& Event ) = 0;
virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) { }
virtual void ReCreateHToolbar() = 0;
virtual void ReCreateVToolbar() = 0;
virtual void OnLeftClick( wxDC* DC,
const wxPoint& MousePos ) = 0;
virtual void OnLeftDClick( wxDC* DC,
const wxPoint& MousePos ) = 0;
virtual bool OnRightClick( const wxPoint& MousePos,
wxMenu* PopMenu ) = 0;
virtual void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) = 0;
virtual void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) = 0;
virtual bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) = 0;
virtual void ReCreateMenuBar();
virtual void SetToolID( int aId, int aCursor, const wxString& aToolMsg );
virtual void UpdateStatusBar();
......@@ -161,11 +157,10 @@ public:
* of "selecting" an item more formal, and to indivisibly tie the operation
* of selecting an item to displaying it using BOARD_ITEM::Display_Infos().
* @param aItem The BOARD_ITEM to make the selected item or NULL if none.
* @param aDisplayInfo = true to display item info, false if not (default =
*true)
* @param aDisplayInfo = true to display item info, false if not (default = true)
*/
void SetCurItem( BOARD_ITEM* aItem,
bool aDisplayInfo = true );
void SetCurItem( BOARD_ITEM* aItem, bool aDisplayInfo = true );
BOARD_ITEM* GetCurItem();
/**
......@@ -256,8 +251,7 @@ public:
void RotateTextModule( TEXTE_MODULE* Text, wxDC* DC );
void DeleteTextModule( TEXTE_MODULE* Text );
void PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC );
void StartMoveTexteModule( TEXTE_MODULE* Text,
wxDC* DC );
void StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC );
TEXTE_MODULE* CreateTextModule( MODULE* Module, wxDC* DC );
/**
......@@ -279,8 +273,7 @@ public:
void ResetModuleTextSizes( int aType, wxDC* aDC );
void InstallPadOptionsFrame( D_PAD* pad );
void InstallTextModOptionsFrame( TEXTE_MODULE* TextMod,
wxDC* DC );
void InstallTextModOptionsFrame( TEXTE_MODULE* TextMod, wxDC* DC );
void AddPad( MODULE* Module, bool draw );
......@@ -299,9 +292,7 @@ public:
void PlacePad( D_PAD* Pad, wxDC* DC );
void Export_Pad_Settings( D_PAD* aPad );
void Import_Pad_Settings( D_PAD* aPad, bool aDraw );
void Global_Import_Pad_Settings( D_PAD* aPad,
bool aDraw );
void Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw );
// loading footprints
......@@ -333,8 +324,7 @@ public:
* having one (or more) of these keywords in their
* keyword list ( aKeyWord = wxEmptyString if not used )
*
* @return wxEmptyString if abort or fails, or the selected module name if
* Ok
* @return wxEmptyString if abort or fails, or the selected module name if Ok
*/
wxString Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow,
const wxString& aLibraryFullFilename,
......@@ -385,13 +375,41 @@ public:
void DrawGeneralRatsnest( wxDC* aDC, int aNetcode = 0 );
void trace_ratsnest_pad( wxDC* DC );
void build_ratsnest_pad( BOARD_ITEM* ref,
const wxPoint& refpos,
bool init );
void build_ratsnest_pad( BOARD_ITEM* ref, const wxPoint& refpos, bool init );
void Tst_Ratsnest( wxDC* DC, int ref_netcode );
void test_connexions( wxDC* DC );
void test_1_net_connexion( wxDC* DC, int net_code );
/**
* Function TestConnections
* tests the connections relative to all nets.
* <p>
* This function update the status of the ratsnest ( flag CH_ACTIF = 0 if a connection
* is found, = 1 else) track segments are assumed to be sorted by net codes.
* This is the case because when a new track is added, it is inserted in the linked list
* according to its net code. and when nets are changed (when a new netlist is read)
* tracks are sorted before using this function.
* </p>
* @param aDC = current Device Context
*/
void TestConnections( wxDC* aDC );
/**
* Function TestNetConnection
* tests the connections relative to \a aNetCode. Track segments are assumed to be
* sorted by net codes.
* @param aDC Cyrrent Device Context
* @param aNetCode The net code to test
*/
void TestNetConnection( wxDC* aDC, int aNetCode );
/**
* Function RecalculateAllTracksNetcode
* search connections between tracks and pads and propagate pad net codes to the track
* segments.
* <p>
* This is a 2 pass computation. First we search a connection between a track segment
* and a pad. If the connection is found, the segment netcode is set to the pad netcode.
*/
void RecalculateAllTracksNetcode();
/* Plotting functions:
......@@ -415,6 +433,7 @@ public:
void Plot_Layer( PLOTTER* plotter,
int Layer,
GRTraceMode trace_mode );
/**
* Function Plot_Standard_Layer
* plot copper or technical layers.
......@@ -432,9 +451,7 @@ public:
bool aPlotVia, GRTraceMode aPlotMode,
bool aSkipNPTH_Pads = false );
void Plot_Serigraphie( PLOTTER* plotter,
int masque_layer,
GRTraceMode trace_mode );
void Plot_Serigraphie( PLOTTER* plotter, int masque_layer, GRTraceMode trace_mode );
/**
* Function PlotDrillMark
......@@ -447,9 +464,7 @@ public:
* @param aSmallDrillShape = true to plot a small drill shape, false to
* plot the actual drill shape
*/
void PlotDrillMark( PLOTTER* aPlotter,
GRTraceMode aTraceMode,
bool aSmallDrillShape );
void PlotDrillMark( PLOTTER* aPlotter, GRTraceMode aTraceMode, bool aSmallDrillShape );
/* Functions relative to Undo/redo commands:
*/
......@@ -484,8 +499,7 @@ public:
// layerhandling:
// (See pcbnew/sel_layer.cpp for description of why null_layer parameter
// is provided)
int SelectLayer( int default_layer, int min_layer, int max_layer,
bool null_layer = false );
int SelectLayer( int default_layer, int min_layer, int max_layer, bool null_layer = false );
void SelectLayerPair();
virtual void SwitchLayer( wxDC* DC, int layer );
......
/***********************************************************/
/* wxPcbStruct.h */
/***********************************************************/
/**
* @file wxPcbStruct.h
*/
#ifndef WXPCB_STRUCT_H
#define WXPCB_STRUCT_H
......@@ -194,8 +194,7 @@ public:
* @param aPrintMirrorMode = true to plot mirrored
* @param aData = a pointer on an auxiliary data (NULL if not used)
*/
virtual void PrintPage( wxDC* aDC,
int aPrintMaskLayer, bool aPrintMirrorMode,
virtual void PrintPage( wxDC* aDC, int aPrintMaskLayer, bool aPrintMirrorMode,
void * aData = NULL );
void GetKicadAbout( wxCommandEvent& event );
......@@ -372,6 +371,7 @@ public:
* <p>
* Reloads the 3D view if required and calls the base PCB_BASE_FRAME::OnModify function
* to update auxiliary information.
* </p>
*/
virtual void OnModify();
......@@ -475,7 +475,7 @@ public:
* Put data pointed by List in the previous state, i.e. the state memorized by List
* @param aList = a PICKED_ITEMS_LIST pointer to the list of items to undo/redo
* @param aRedoCommand = a bool: true for redo, false for undo
* @param aRebuildRatsnet = a bool: true to rebuild ratsnet (normal use), false
* @param aRebuildRatsnet = a bool: true to rebuild ratsnest (normal use), false
* to just retrieve last state (used in abort commands that do not need to
* rebuild ratsnest)
*/
......@@ -780,8 +780,7 @@ public:
* @param aUndoPickList = the undo list used to save OldModule. If null,
* OldModule is deleted
*/
void Exchange_Module( MODULE* aOldModule,
MODULE* aNewModule,
void Exchange_Module( MODULE* aOldModule, MODULE* aNewModule,
PICKED_ITEMS_LIST* aUndoPickList );
// loading modules: see PCB_BASE_FRAME
......@@ -797,7 +796,6 @@ public:
*/
void OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem );
// Highlight functions:
int Select_High_Light( wxDC* DC );
void High_Light( wxDC* DC );
......@@ -910,12 +908,39 @@ public:
void Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On );
void Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On );
void Attribut_net( wxDC* DC, int net_code, bool Flag_On );
void Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int command );
/**
* Function StartMoveOneNodeOrSegment
* initializes the parameters to move one via or/and a terminal point of a track segment
* The terminal point of other connected segments (if any) are moved too.
*/
void StartMoveOneNodeOrSegment( TRACK* aTrack, wxDC* aDC, int aCommand );
bool PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC );
/**
* @todo This function is broken, because it merge segments having different
* widths or without any connectivity test.
* 2 collinear segments can be merged only if no other segment or via is
* connected to the common point and if they have the same width. See
* cleanup.cpp for merge functions and consider MarkTrace() to locate segments
* that can be merged
*/
bool MergeCollinearTracks( TRACK* track, wxDC* DC, int end );
void Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC );
void SwitchLayer( wxDC* DC, int layer );
bool Add_45_degrees_Segment( wxDC* DC );
/**
* Function Add45DegreeSegment
* adds a track segment between 2 tracks segments if these 2 segments
* make a 90 deg angle, in order to have 45 deg track segments
* Its only works on horizontal or vertical segments.
*
* @param aDC The wxDC device context to draw on.
* @return A bool value true if ok or false if not.
*/
bool Add45DegreeSegment( wxDC* aDC );
/**
* Function EraseRedundantTrack
......@@ -965,7 +990,6 @@ public:
*/
void Delete_OldZone_Fill( SEGZONE* aZone, long aTimestamp = 0 );
/**
* Function Delete_LastCreatedCorner
* Used only while creating a new zone outline
......@@ -1107,7 +1131,6 @@ public:
DIMENSION* Begin_Dimension( DIMENSION* Dimension, wxDC* DC );
void Delete_Dimension( DIMENSION* Dimension, wxDC* DC );
// netlist handling:
void InstallNetlistFrame( wxDC* DC );
......@@ -1227,6 +1250,7 @@ public:
* application name appended with no file. Otherwise, the title is set to the full path
* and file name and read only is appended to the title if the user does not have write
* access to the file.
* </p>
*/
void UpdateTitle();
......
......@@ -6,9 +6,8 @@
#include "common.h"
#include "pcbnew.h"
#include "class_board_design_settings.h"
#include "colors_selection.h"
#include "class_board.h"
/* This is an odd place for this, but cvpcb won't link if it is
* in class_board_item.cpp like I first tried it.
......@@ -32,10 +31,8 @@ BOARD::BOARD( EDA_ITEM* parent, PCB_BASE_FRAME* frame ) :
m_NbNoconnect = 0; // Number of unconnected nets.
m_CurrentZoneContour = NULL; // This ZONE_CONTAINER handle the
// zone contour currently in
// progress
m_NetInfo = new NETINFO_LIST( this ); // handle nets info list (name,
// design constraints ..
// zone contour currently in progress
m_NetInfo = new NETINFO_LIST( this ); // handle nets info list (name, design constraints ..
m_NetInfo->BuildListOfNets(); // prepare pads and nets lists containers.
for( int layer = 0; layer < NB_COPPER_LAYERS; ++layer )
......@@ -45,11 +42,9 @@ BOARD::BOARD( EDA_ITEM* parent, PCB_BASE_FRAME* frame ) :
}
// Initial parameters for the default NETCLASS come from the global
// preferences
// within g_DesignSettings via the NETCLASS() constructor.
// preferences within g_DesignSettings via the NETCLASS() constructor.
// Should user eventually load a board from a disk file, then these
// defaults
// will get overwritten during load.
// defaults will get overwritten during load.
m_NetClasses.GetDefault()->SetDescription( _( "This is the default net class." ) );
m_ViaSizeSelector = 0;
m_TrackWidthSelector = 0;
......@@ -1340,8 +1335,10 @@ bool BOARD::Save( FILE* aFile ) const
fprintf( aFile, "$TRACK\n" );
for( item = m_Track; item; item = item->Next() )
{
if( !item->Save( aFile ) )
goto out;
}
fprintf( aFile, "$EndTRACK\n" );
......@@ -1349,8 +1346,10 @@ bool BOARD::Save( FILE* aFile ) const
fprintf( aFile, "$ZONE\n" );
for( item = m_Zone; item; item = item->Next() )
{
if( !item->Save( aFile ) )
goto out;
}
fprintf( aFile, "$EndZONE\n" );
......@@ -1492,6 +1491,149 @@ TRACK* BOARD::GetViaByPosition( const wxPoint& aPosition, int aLayerMask )
}
D_PAD* BOARD::GetPad( const wxPoint& aPosition, int aLayerMask )
{
D_PAD* pad = NULL;
for( MODULE* module = m_Modules; module && ( pad == NULL ); module = module->Next() )
{
if( aLayerMask )
pad = module->GetPad( aPosition, aLayerMask );
else
pad = module->GetPad( aPosition, ALL_LAYERS );
}
return pad;
}
D_PAD* BOARD::GetPad( TRACK* aTrace, int aEndPoint )
{
D_PAD* pad = NULL;
wxPoint aPosition;
int aLayerMask = g_TabOneLayerMask[aTrace->GetLayer()];
if( aEndPoint == START )
{
aPosition = aTrace->m_Start;
}
else
{
aPosition = aTrace->m_End;
}
for( MODULE* module = m_Modules; module; module = module->Next() )
{
pad = module->GetPad( aPosition, aLayerMask );
if( pad != NULL )
break;
}
return pad;
}
D_PAD* BOARD::GetPadFast( const wxPoint& aPosition, int aLayerMask )
{
for( unsigned i=0; i<GetPadsCount(); ++i )
{
D_PAD* pad = m_NetInfo->GetPad(i);
if( pad->m_Pos != aPosition )
continue;
/* Pad found, it must be on the correct layer */
if( pad->m_layerMask & aLayerMask )
return pad;
}
return NULL;
}
D_PAD* BOARD::GetPad( LISTE_PAD* aPad, const wxPoint& aPosition, int aLayerMask )
{
D_PAD* pad;
int ii;
int nb_pad = GetPadsCount();
LISTE_PAD* ptr_pad = aPad;
LISTE_PAD* lim = aPad + nb_pad - 1;
ptr_pad = aPad;
while( nb_pad )
{
pad = *ptr_pad;
ii = nb_pad;
nb_pad >>= 1;
if( (ii & 1) && ( ii > 1 ) )
nb_pad++;
if( pad->m_Pos.x < aPosition.x ) /* Must search after this item */
{
ptr_pad += nb_pad;
if( ptr_pad > lim )
ptr_pad = lim;
continue;
}
if( pad->m_Pos.x > aPosition.x ) /* Must search before this item */
{
ptr_pad -= nb_pad;
if( ptr_pad < aPad )
ptr_pad = aPad;
continue;
}
/* A suitable block is found (X coordinate matches the px reference: but we
* must matches the Y coordinate */
if( pad->m_Pos.x == aPosition.x )
{
/* Search the beginning of the block */
while( ptr_pad >= aPad )
{
pad = *ptr_pad;
if( pad->m_Pos.x == aPosition.x )
ptr_pad--;
else
break;
}
ptr_pad++; /* ptr_pad = first pad which have pad->m_Pos.x = px */
for( ; ; ptr_pad++ )
{
if( ptr_pad > lim )
return NULL; /* outside suitable block */
pad = *ptr_pad;
if( pad->m_Pos.x != aPosition.x )
return NULL; /* outside suitable block */
if( pad->m_Pos.y != aPosition.y )
continue;
/* A Pad if found here: but it must mach the layer */
if( pad->m_layerMask & aLayerMask ) // Matches layer => a connected pad is found!
return pad;
}
}
}
return NULL;
}
#if defined(DEBUG)
void BOARD::Show( int nestLevel, std::ostream& os )
......
......@@ -7,6 +7,7 @@
#include "dlist.h"
#include "class_netinfo.h"
#include "class_pad.h"
#include "class_colors_design_settings.h"
#include "class_board_design_settings.h"
......@@ -1091,6 +1092,55 @@ public:
* @return TRACK* A point a to the SEGVIA object if found, else NULL.
*/
TRACK* GetViaByPosition( const wxPoint& aPosition, int aLayerMask = -1 );
/**
* Function GetPad
* finds a pad \a aPosition on \a aLayer.
*
* @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 GetPad
* finds a pad connected to \a aEndPoint of \a aTrace.
*
* @param aTrace A pointer to a TRACK object to hit test against.
* @param aEndPoint The end point of \a aTrace the hit test against.
* @return A pointer to a D_PAD object if found or NULL if not found.
*/
D_PAD* GetPad( TRACK* aTrace, int aEndPoint );
/**
* Function GetPadFast
* return pad found at \a aPosition on \a aLayer uning the fast search method.
* <p>
* The fast search method only works if the pad list has already been built.
* </p>
* @param aPosition A wxPoint object containing the position to hit test.
* @param aLayer 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* GetPadFast( const wxPoint& aPosition, int aLayer );
/**
* Function GetPad
* locates the pad connected at \a aPosition on \a aLayer starting at list postion
* \a aPad
* <p>
* This function uses a fast search in this sorted pad list and it is faster than
* GetPadFast(). This list is a sorted pad list must be built before calling this
* function.
* </p>
* @note The normal pad list #m_Pads is sorted by increasing netcodes.
* @param aPad A D_PAD object pointer the first pad in the list to begin searching.
* @param aPosition A wxPoint object containing the position to test.
* @param aLayerMast A layer or layers to mask the hit test.
* @return A D_PAD object pointer to the connected pad.
*/
D_PAD* GetPad( LISTE_PAD* aPad, const wxPoint& aPosition, int aLayerMask );
};
#endif // #ifndef CLASS_BOARD_H
......@@ -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
SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] )
......
/*******************************************************/
/* class_module.h : module description (excepted pads) */
/*******************************************************/
/**
* @file class_module.h
* @brief Module description (excepted pads)
*/
#ifndef _MODULE_H_
......@@ -54,7 +55,7 @@ public:
int m_Attributs; /* Flag bits ( see Mod_Attribut ) */
int m_Orient; /* orientation in 0.1 degrees */
int flag; /* Use to trace rastnest and auto
int flag; /* Use to trace ratsnest and auto
* routing. */
int m_ModuleStatus; /* For autoplace: flags (LOCKED,
* AUTOPLACED) */
......@@ -129,7 +130,7 @@ public:
/**
* Function GetBoundingBox
* returns the bounding box of this
* tootprint. Mainly used to redraw the screen area occupied by
* footprint. Mainly used to redraw the screen area occupied by
* the footprint.
* @return EDA_RECT - The rectangle containing the footprint and texts.
*/
......@@ -148,6 +149,7 @@ public:
// Moves
void SetPosition( const wxPoint& newpos );
void SetOrientation( int newangle );
/**
......@@ -209,6 +211,7 @@ public:
bool Save( FILE* aFile ) const;
int Write_3D_Descr( FILE* File ) const;
int ReadDescr( LINE_READER* aReader );
/**
......@@ -219,6 +222,7 @@ public:
* @return bool - true if success reading else false.
*/
bool Read_GPCB_Descr( const wxString& CmpFullFileName );
int Read_3D_Descr( LINE_READER* aReader );
/* drawing functions */
......@@ -237,7 +241,9 @@ public:
const wxPoint& aOffset = ZeroOffset );
void Draw3D( Pcb3D_GLCanvas* glcanvas );
void DrawEdgesOnly( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, int draw_mode );
void DrawAncre( EDA_DRAW_PANEL* panel, wxDC* DC,
const wxPoint& offset, int dim_ancre, int draw_mode );
......@@ -249,7 +255,6 @@ public:
*/
void DisplayInfo( EDA_DRAW_FRAME* frame );
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
......@@ -258,7 +263,6 @@ public:
*/
bool HitTest( const wxPoint& aRefPos );
/**
* Function HitTest (overlaid)
* tests if the given EDA_RECT intersect the bounds of this object.
......@@ -297,6 +301,15 @@ public:
*/
D_PAD* FindPadByName( const wxString& aPadName ) const;
/**
* Function GetPad
* get a pad at \a aPosition on \a aLayer in the footprint.
*
* @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 otherwise NULL.
*/
D_PAD* GetPad( const wxPoint& aPosition, int aLayerMask = ALL_LAYERS );
/**
* Function Visit
......@@ -314,7 +327,6 @@ public:
SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] );
/**
* Function GetClass
* returns the class name.
......
This diff is collapsed.
This diff is collapsed.
......@@ -107,7 +107,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack )
SaveCopyInUndoList( aTrack, UR_DELETED );
OnModify();
test_1_net_connexion( DC, current_net_code );
TestNetConnection( DC, current_net_code );
GetBoard()->DisplayInfo( this );
return NULL;
}
......@@ -120,7 +120,7 @@ void PCB_EDIT_FRAME::Delete_Track( wxDC* DC, TRACK* aTrack )
int current_net_code = aTrack->GetNet();
Remove_One_Track( DC, aTrack );
OnModify();
test_1_net_connexion( DC, current_net_code );
TestNetConnection( DC, current_net_code );
}
}
......@@ -160,7 +160,7 @@ void PCB_EDIT_FRAME::Delete_net( wxDC* DC, TRACK* aTrack )
SaveCopyInUndoList( itemsList, UR_DELETED );
OnModify();
test_1_net_connexion( DC, net_code_delete );
TestNetConnection( DC, net_code_delete );
GetBoard()->DisplayInfo( this );
}
......@@ -214,5 +214,5 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
SaveCopyInUndoList( itemsList, UR_DELETED );
if( net_code > 0 )
test_1_net_connexion( DC, net_code );
TestNetConnection( DC, net_code );
}
......@@ -326,8 +326,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
else
{
int v_type = GetBoard()->GetBoardDesignSettings()->m_CurrentViaType;
// place micro via and switch layer.
if( id == ID_POPUP_PCB_PLACE_MICROVIA )
GetBoard()->GetBoardDesignSettings()->m_CurrentViaType = VIA_MICROVIA; // place micro via and switch layer
GetBoard()->GetBoardDesignSettings()->m_CurrentViaType = VIA_MICROVIA;
Other_Layer_Route( (TRACK*) GetCurItem(), &dc );
GetBoard()->GetBoardDesignSettings()->m_CurrentViaType = v_type;
......@@ -400,7 +402,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
int netcode = zsegm->GetNet();
Delete_OldZone_Fill( zsegm );
SetCurItem( NULL );
test_1_net_connexion( NULL, netcode );
TestNetConnection( NULL, netcode );
OnModify();
GetBoard()->DisplayInfo( this );
}
......@@ -430,7 +432,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
int netcode = ( (ZONE_CONTAINER*) GetCurItem() )->GetNet();
Delete_Zone_Contour( &dc, (ZONE_CONTAINER*) GetCurItem() );
SetCurItem( NULL );
test_1_net_connexion( NULL, netcode );
TestNetConnection( NULL, netcode );
GetBoard()->DisplayInfo( this );
}
break;
......@@ -445,10 +447,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MoveCursorToCrossHair();
ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
DrawPanel->m_AutoPAN_Request = true;
Start_Move_Zone_Corner( &dc,
zone_cont,
zone_cont->m_CornerSelection,
false );
Start_Move_Zone_Corner( &dc, zone_cont, zone_cont->m_CornerSelection, false );
break;
}
......@@ -457,9 +456,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MoveCursorToCrossHair();
ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
DrawPanel->m_AutoPAN_Request = true;
Start_Move_Zone_Drag_Outline_Edge( &dc,
zone_cont,
zone_cont->m_CornerSelection );
Start_Move_Zone_Drag_Outline_Edge( &dc, zone_cont, zone_cont->m_CornerSelection );
break;
}
......@@ -487,10 +484,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
zone_cont->m_CornerSelection++;
zone_cont->Draw( DrawPanel, &dc, GR_XOR );
DrawPanel->m_AutoPAN_Request = true;
Start_Move_Zone_Corner( &dc,
zone_cont,
zone_cont->m_CornerSelection,
true );
Start_Move_Zone_Corner( &dc, zone_cont, zone_cont->m_CornerSelection, true );
break;
}
......@@ -515,7 +509,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
ZONE_CONTAINER* zone_container = (ZONE_CONTAINER*) GetCurItem();
zone_container->UnFill();
test_1_net_connexion( NULL, zone_container->GetNet() );
TestNetConnection( NULL, zone_container->GetNet() );
OnModify();
GetBoard()->DisplayInfo( this );
DrawPanel->Refresh();
......@@ -534,7 +528,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
}
SetCurItem( NULL ); // CurItem might be deleted by this command, clear the pointer
test_connexions( NULL );
TestConnections( NULL );
Tst_Ratsnest( NULL, 0 ); // Recalculate the active ratsnest, i.e. the unconnected links
OnModify();
GetBoard()->DisplayInfo( this );
......@@ -544,7 +538,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_FILL_ZONE:
DrawPanel->MoveCursorToCrossHair();
Fill_Zone( (ZONE_CONTAINER*) GetCurItem() );
test_1_net_connexion( NULL, ( (ZONE_CONTAINER*) GetCurItem() )->GetNet() );
TestNetConnection( NULL, ( (ZONE_CONTAINER*) GetCurItem() )->GetNet() );
GetBoard()->DisplayInfo( this );
DrawPanel->Refresh();
break;
......@@ -560,6 +554,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_MOVE_MODULE_REQUEST:
if( GetCurItem() == NULL )
break;
// If the current Item is a pad, text module ...: Get its parent
if( GetCurItem()->Type() != TYPE_MODULE )
SetCurItem( GetCurItem()->GetParent() );
......@@ -655,7 +650,8 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
}
if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple rotation, no other edition in progress */
/* This is a simple rotation, no other editing in progress */
if( !(GetCurItem()->m_Flags & IS_MOVED) )
SaveCopyInUndoList(GetCurItem(), UR_ROTATED, ((MODULE*)GetCurItem())->m_Pos);
Rotate_Module( &dc, (MODULE*) GetCurItem(), g_RotationAngle, true );
......@@ -682,8 +678,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
}
if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple rotation, no other edition in progress */
SaveCopyInUndoList(GetCurItem(), UR_ROTATED_CLOCKWISE, ((MODULE*)GetCurItem())->m_Pos);
/* This is a simple rotation, no other editing in progress */
if( !(GetCurItem()->m_Flags & IS_MOVED) )
SaveCopyInUndoList( GetCurItem(), UR_ROTATED_CLOCKWISE,
((MODULE*)GetCurItem())->m_Pos );
Rotate_Module( &dc, (MODULE*) GetCurItem(), -g_RotationAngle, true );
break;
......@@ -709,7 +707,8 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
}
if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple flip, no other edition in progress */
/* This is a simple flip, no other editing in progress */
if( !(GetCurItem()->m_Flags & IS_MOVED) )
SaveCopyInUndoList(GetCurItem(), UR_FLIPPED, ((MODULE*)GetCurItem())->m_Pos);
Change_Side_Module( (MODULE*) GetCurItem(), &dc );
......@@ -981,13 +980,13 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_MOVE_TRACK_SEGMENT:
DrawPanel->MoveCursorToCrossHair();
Start_MoveOneNodeOrSegment( (TRACK*) GetScreen()->GetCurItem(), &dc, id );
StartMoveOneNodeOrSegment( (TRACK*) GetScreen()->GetCurItem(), &dc, id );
break;
case ID_POPUP_PCB_DRAG_TRACK_SEGMENT:
case ID_POPUP_PCB_MOVE_TRACK_NODE:
DrawPanel->MoveCursorToCrossHair();
Start_MoveOneNodeOrSegment( (TRACK*) GetScreen()->GetCurItem(), &dc, id );
StartMoveOneNodeOrSegment( (TRACK*) GetScreen()->GetCurItem(), &dc, id );
break;
case ID_POPUP_PCB_DRAG_TRACK_SEGMENT_KEEP_SLOPE:
......@@ -1007,7 +1006,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
track->Draw( DrawPanel, &dc, GR_XOR );
newtrack->Draw( DrawPanel, &dc, GR_XOR );
/* compute the new ratsnest, because connectivity could change */
test_1_net_connexion( &dc, track->GetNet() );
TestNetConnection( &dc, track->GetNet() );
}
break;
......@@ -1130,7 +1129,7 @@ void PCB_EDIT_FRAME::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
SetCurItem( NULL );
int netcode = ( (ZONE_CONTAINER*) Item )->GetNet();
Delete_Zone_Contour( DC, (ZONE_CONTAINER*) Item );
test_1_net_connexion( NULL, netcode );
TestNetConnection( NULL, netcode );
GetBoard()->DisplayInfo( this );
}
break;
......
......@@ -196,7 +196,7 @@ void PCB_EDIT_FRAME::DisplayNetStatus( wxDC* DC )
if( pt_segm == NULL )
GetBoard()->DisplayInfo( this );
else
test_1_net_connexion( DC, pt_segm->GetNet() );
TestNetConnection( DC, pt_segm->GetNet() );
}
......
This diff is collapsed.
......@@ -12,88 +12,6 @@
#include "protos.h"
/* Locate the pad CONNECTED to a track
* input: ptr_trace: pointer to the segment of track
* Extr = flag = START -> beginning of the test segment
* END -> end of the segment to be tested
* Returns:
* A pointer to the description of the pad if found.
* NULL pointer if pad NOT FOUND
*/
D_PAD* Locate_Pad_Connecte( BOARD* Pcb, TRACK* ptr_trace, int extr )
{
D_PAD* ptr_pad = NULL;
wxPoint ref_pos;
int aLayerMask = g_TabOneLayerMask[ptr_trace->GetLayer()];
if( extr == START )
{
ref_pos = ptr_trace->m_Start;
}
else
{
ref_pos = ptr_trace->m_End;
}
for( MODULE* module = Pcb->m_Modules; module; module = module->Next() )
{
ptr_pad = Locate_Pads( module, ref_pos, aLayerMask );
if( ptr_pad != NULL )
break;
}
return ptr_pad;
}
/*
* Locate a pad pointed to by the coordinates ref_pos.x, ref_pos.y
* aLayerMask is allowed layers ( bitmap mask)
* Returns:
* Pointer to a pad if found or NULL
*/
D_PAD* Locate_Any_Pad( BOARD* Pcb, const wxPoint& ref_pos, int aLayerMask )
{
D_PAD* pad = NULL;
for( MODULE* module=Pcb->m_Modules; module && ( pad == NULL ); module = module->Next() )
{
if( aLayerMask )
pad = Locate_Pads( module, ref_pos, aLayerMask );
else
pad = Locate_Pads( module, ref_pos, ALL_LAYERS );
}
return pad;
}
/* Locate the pad pointed to by the coordinate ref_pos.x,, ref_pos.y
* Input:
* - the footprint to test
* - masque_layer layer(s) (bit_masque) which must be the pad
* Returns:
* A pointer to the pad if found or NULL
*/
D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int aLayerMask )
{
for( D_PAD* pt_pad = module->m_Pads; pt_pad; pt_pad = pt_pad->Next() )
{
/* ... and on the correct layer. */
if( ( pt_pad->m_layerMask & aLayerMask ) == 0 )
continue;
if( pt_pad->HitTest( ref_pos ) )
return pt_pad;
}
return NULL;
}
/**
* Function Locate_Prefered_Module
* locates a footprint by its bounding rectangle. If several footprints
......@@ -402,58 +320,6 @@ TRACK* GetTrace( BOARD* aPcb, TRACK* start_adresse, const wxPoint& ref_pos, int
}
/*
* 1 - Locate zone area by the mouse.
* 2 - Locate zone area by point
* def_pos.x, ref_pos.y.r
*
* If layer == -1, tst layer is not
*
* The search begins to address start_adresse
*/
TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int layer )
{
for( TRACK* Zone = start_adresse; Zone; Zone = Zone->Next() )
{
if( (layer != -1) && (Zone->GetLayer() != layer) )
continue;
if( Zone->HitTest( ref_pos ) )
return Zone;
}
return NULL;
}
/* Find the pad center px, py,
* The layer INDICATED BY aLayerMask (bitwise)
* (Runway end)
* The list of pads must already exist.
*
* Returns:
* NULL if no pad located.
* Pointer to the structure corresponding descr_pad if pad found
* (Good position and good layer).
*/
D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int aLayerMask )
{
for( unsigned i=0; i<Pcb->GetPadsCount(); ++i )
{
D_PAD* pad = Pcb->m_NetInfo->GetPad(i);
if( pad->m_Pos != ref_pos )
continue;
/* Pad found, it must be on the correct layer */
if( pad->m_layerMask & aLayerMask )
return pad;
}
return NULL;
}
/* Locate segment with one end that coincides with the point x, y
* Data on layers by masklayer
* Research is done to address start_adr has end_adr
......
......@@ -153,7 +153,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr
if( doPad )
{
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 )
{
......
This diff is collapsed.
......@@ -92,49 +92,10 @@ TRACK* GetConnectedTrace( TRACK* aTrace, TRACK* pt_base, TRACK* pt_lim, int extr
*/
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.
*/
......@@ -142,26 +103,6 @@ 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 */
/*************/
......@@ -185,9 +126,9 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
void CalculateSegmentEndPoint( const wxPoint& aPosition, int ox, int oy, int* fx, int* fy );
/*****************/
/***************/
/* TRACK.CPP : */
/*****************/
/***************/
/**
* Function MarkTrace
......
......@@ -118,8 +118,7 @@ void PCB_BASE_FRAME::Compile_Ratsnest( wxDC* aDC, bool aDisplayStatus )
DisplayRastnestInProgress = true;
GetBoard()->m_Status_Pcb = 0; /* we want a full ratsnest computation,
* from the scratch */
GetBoard()->m_Status_Pcb = 0; /* we want a full ratsnest computation, from the scratch */
ClearMsgPanel();
// Rebuild the full pads and net info list
......@@ -142,9 +141,8 @@ void PCB_BASE_FRAME::Compile_Ratsnest( wxDC* aDC, bool aDisplayStatus )
*/
Build_Board_Ratsnest( aDC );
/* Compute the pad connections due to the existing tracks (physical
* connections) */
test_connexions( aDC );
/* Compute the pad connections due to the existing tracks (physical connections) */
TestConnections( aDC );
/* Compute the active ratsnest, i.e. the unconnected links
* it is faster than Build_Board_Ratsnest()
......@@ -410,7 +408,7 @@ static int gen_rats_pad_to_pad( vector<RATSNEST_ITEM>& aRatsnestBuffer,
* Update :
* nb_nodes = Active pads count for the board
* nb_links = link count for the board (logical connection count)
* (there are n-1 links for an equipotent which have n active pads) .
* (there are n-1 links for an connection which have n active pads) .
*
*/
void PCB_BASE_FRAME::Build_Board_Ratsnest( wxDC* DC )
......@@ -512,8 +510,7 @@ void PCB_BASE_FRAME::Build_Board_Ratsnest( wxDC* DC )
m_Pcb->m_FullRatsnest[ii].m_Status &= ~CH_VISIBLE;
if( DC )
m_Pcb->m_FullRatsnest[ii].Draw( DrawPanel, DC, GR_XOR,
wxPoint( 0, 0 ) );
m_Pcb->m_FullRatsnest[ii].Draw( DrawPanel, DC, GR_XOR, wxPoint( 0, 0 ) );
}
}
......@@ -620,7 +617,7 @@ static int tst_rats_block_to_block( NETINFO_ITEM* net,
/**
* Function used by Tst_Ratsnest_general
* The general ratsnest list must exists
* Activates the ratsnest between 2 pads ( supposes du meme net )
* Activates the ratsnest between 2 pads ( assumes the same net )
* The function links 1 pad not already connected an other pad and activate
* some blocks linked by a ratsnest
* Its test only the existing ratsnest and activate some ratsnest (status bit
......@@ -933,6 +930,7 @@ CalculateExternalRatsnest:
local_rats.m_Lenght = 0x7FFFFFFF;
local_rats.m_Status = 0;
bool addRats = false;
if( internalRatsCount < m_Pcb->m_LocalRatsnest.size() )
m_Pcb->m_LocalRatsnest.erase( m_Pcb->m_LocalRatsnest.begin() + internalRatsCount,
m_Pcb->m_LocalRatsnest.end() );
......
......@@ -242,6 +242,7 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int two_sides )
s_Clearance = GetBoard()->m_NetClasses.GetDefault()->GetClearance();
Ncurrent = 0;
/* go until no more work to do */
GetWork( &row_source, &col_source, &current_net_code,
&row_target, &col_target, &pt_cur_ch ); // First net to route.
......@@ -333,7 +334,7 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int two_sides )
msg.Printf( wxT( "%d" ), nbunsucces );
AppendMsgPanel( wxT( "Fail" ), msg, RED );
msg.Printf( wxT( " %d" ), GetBoard()->m_NbNoconnect );
AppendMsgPanel( wxT( "Not Connectd" ), msg, CYAN );
AppendMsgPanel( wxT( "Not Connected" ), msg, CYAN );
/* Delete routing from display. */
pt_cur_ch->m_PadStart->Draw( DrawPanel, DC, GR_AND );
......@@ -407,6 +408,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
/* Set tab_masque[side] for final test of routing. */
tab_mask[TOP] = topLayerMask;
tab_mask[BOTTOM] = bottomLayerMask;
/* Set active layers mask. */
routeLayerMask = topLayerMask | bottomLayerMask;
......@@ -1268,14 +1270,12 @@ static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
g_CurrentTrackList.PushBack( newTrack );
}
g_FirstTrackSegment->start = Locate_Pad_Connecte( pcbframe->GetBoard(),
g_FirstTrackSegment, START );
g_FirstTrackSegment->start = pcbframe->GetBoard()->GetPad( g_FirstTrackSegment, START );
if( g_FirstTrackSegment->start )
g_FirstTrackSegment->SetState( BEGIN_ONPAD, ON );
g_CurrentTrackSegment->end = Locate_Pad_Connecte( pcbframe->GetBoard(),
g_CurrentTrackSegment, END );
g_CurrentTrackSegment->end = pcbframe->GetBoard()->GetPad( g_CurrentTrackSegment, END );
if( g_CurrentTrackSegment->end )
g_CurrentTrackSegment->SetState( END_ONPAD, ON );
......@@ -1304,7 +1304,7 @@ static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
DrawTraces( panel, DC, firstTrack, newCount, GR_OR );
pcbframe->test_1_net_connexion( DC, netcode );
pcbframe->TestNetConnection( DC, netcode );
screen->SetModify();
}
......@@ -287,8 +287,7 @@ static void ChainMarkedSegments( BOARD* aPcb,
TRACK* pt_segm, // The current segment being analyzed.
* pt_via, // The via identified, eventually destroy
* SegmentCandidate; // The end segment to destroy (or NULL =
// pt_segm
* SegmentCandidate; // The end segment to destroy (or NULL = pt_segm
int NbSegm;
if( aPcb->m_Track == NULL )
......@@ -311,7 +310,7 @@ static void ChainMarkedSegments( BOARD* aPcb,
*/
for( ; ; )
{
if( Fast_Locate_Pad_Connecte( aPcb, aRef_pos, aLayerMask ) != NULL )
if( aPcb->GetPadFast( aRef_pos, aLayerMask ) != NULL )
return;
/* Test for a via: a via changes the layer mask and can connect a lot
......
......@@ -163,7 +163,7 @@ int PCB_EDIT_FRAME::Fill_All_Zones( bool verbose )
}
progressDialog.Update( ii+2, _( "Updating ratsnest..." ) );
test_connexions( NULL );
TestConnections( NULL );
// Recalculate the active ratsnest, i.e. the unconnected links
Tst_Ratsnest( NULL, 0 );
......
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