Commit 3d7c91af authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

PCBNew locate via code refactoring and other minor fixes.

* Refactor via locate code into the appropriate object.
* Rename all HightLight code to HighLight.
* Dead code removal.
parent 5bf7f4cd
Loading
Loading
Loading
Loading
+15 −1
Original line number Original line Diff line number Diff line
@@ -831,7 +831,14 @@ public:
     */
     */
    bool   Other_Layer_Route( TRACK* track, wxDC* DC );
    bool   Other_Layer_Route( TRACK* track, wxDC* DC );
    void   HighlightUnconnectedPads( wxDC* DC );
    void   HighlightUnconnectedPads( wxDC* DC );

    /**
     * Function DisplayNetStatus
     * shows the status of the net at the current mouse position or the
     * PCB status if no segment selected.
     */
    void   DisplayNetStatus( wxDC* DC );
    void   DisplayNetStatus( wxDC* DC );

    TRACK* Delete_Segment( wxDC* DC, TRACK* Track );
    TRACK* Delete_Segment( wxDC* DC, TRACK* Track );
    void   Delete_Track( wxDC* DC, TRACK* Track );
    void   Delete_Track( wxDC* DC, TRACK* Track );
    void   Delete_net( wxDC* DC, TRACK* Track );
    void   Delete_net( wxDC* DC, TRACK* Track );
@@ -900,7 +907,6 @@ public:
     */
     */
    bool   End_Route( TRACK* aTrack, wxDC* aDC );
    bool   End_Route( TRACK* aTrack, wxDC* aDC );


    void   ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC );
    void   Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On );
    void   Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On );
    void   Attribut_Track( 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   Attribut_net( wxDC* DC, int net_code, bool Flag_On );
@@ -1177,7 +1183,15 @@ public:
    void         ReadAutoroutedTracks( wxDC* DC );
    void         ReadAutoroutedTracks( wxDC* DC );
    void         GlobalRoute( wxDC* DC );
    void         GlobalRoute( wxDC* DC );


    /**
     * Function Show_1_Ratsnest
     * draw ratsnest.
     *
     * The net edge pad with mouse or module locates the mouse.
     * Delete the ratsnest if no module or pad is selected.
     */
    void         Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC );
    void         Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC );

    void         Clean_Pcb( wxDC* DC );
    void         Clean_Pcb( wxDC* DC );


    void         InstallFindFrame( const wxPoint& pos, wxDC* DC );
    void         InstallFindFrame( const wxPoint& pos, wxDC* DC );
+40 −122
Original line number Original line Diff line number Diff line
@@ -15,14 +15,11 @@
 */
 */
wxPoint BOARD_ITEM::ZeroOffset( 0, 0 );
wxPoint BOARD_ITEM::ZeroOffset( 0, 0 );



// Current design settings (used also to read configs):
// Current design settings (used also to read configs):
BOARD_DESIGN_SETTINGS boardDesignSettings;
BOARD_DESIGN_SETTINGS boardDesignSettings;




/*****************/
/* Class BOARD: */
/*****************/

BOARD::BOARD( EDA_ITEM* parent, PCB_BASE_FRAME* frame ) :
BOARD::BOARD( EDA_ITEM* parent, PCB_BASE_FRAME* frame ) :
    BOARD_ITEM( (BOARD_ITEM*)parent, TYPE_PCB ),
    BOARD_ITEM( (BOARD_ITEM*)parent, TYPE_PCB ),
    m_NetClasses( this )
    m_NetClasses( this )
@@ -87,36 +84,19 @@ BOARD::~BOARD()
}
}




/*
void BOARD::PushHighLight()
 * Function PushHightLight
 * save current hight light info for later use
 */
void BOARD::PushHightLight()
{
{
    m_hightLightPrevious = m_hightLight;
    m_hightLightPrevious = m_hightLight;
}
}




/*
void BOARD::PopHighLight()
 * Function PopHightLight
 * retrieve a previously saved hight light info
 */
void BOARD::PopHightLight()
{
{
    m_hightLight = m_hightLightPrevious;
    m_hightLight = m_hightLightPrevious;
    m_hightLightPrevious.Clear();
    m_hightLightPrevious.Clear();
}
}




/**
 * Function SetCurrentNetClass
 * Must be called after a netclass selection (or after a netclass parameter
 * change
 * Initialize vias and tracks values displayed in combo boxes of the auxiliary
 * toolbar and some other parameters (netclass name ....)
 * @param aNetClassName = the new netclass name
 * @return true if lists of tracks and vias sizes are modified
 */
bool BOARD::SetCurrentNetClass( const wxString& aNetClassName )
bool BOARD::SetCurrentNetClass( const wxString& aNetClassName )
{
{
    NETCLASS* netClass = m_NetClasses.Find( aNetClassName );
    NETCLASS* netClass = m_NetClasses.Find( aNetClassName );
@@ -165,10 +145,6 @@ bool BOARD::SetCurrentNetClass( const wxString& aNetClassName )
}
}




/**
 * Function GetBiggestClearanceValue
 * @return the biggest clearance value found in NetClasses list
 */
int BOARD::GetBiggestClearanceValue()
int BOARD::GetBiggestClearanceValue()
{
{
    int clearance = m_NetClasses.GetDefault()->GetClearance();
    int clearance = m_NetClasses.GetDefault()->GetClearance();
@@ -184,11 +160,6 @@ int BOARD::GetBiggestClearanceValue()
}
}




/**
 * Function GetCurrentMicroViaSize
 * @return the current micro via size,
 * that is the current netclass value
 */
int BOARD::GetCurrentMicroViaSize()
int BOARD::GetCurrentMicroViaSize()
{
{
    NETCLASS* netclass = m_NetClasses.Find( m_CurrentNetClassName );
    NETCLASS* netclass = m_NetClasses.Find( m_CurrentNetClassName );
@@ -197,11 +168,6 @@ int BOARD::GetCurrentMicroViaSize()
}
}




/**
 * Function GetCurrentMicroViaDrill
 * @return the current micro via drill,
 * that is the current netclass value
 */
int BOARD::GetCurrentMicroViaDrill()
int BOARD::GetCurrentMicroViaDrill()
{
{
    NETCLASS* netclass = m_NetClasses.Find( m_CurrentNetClassName );
    NETCLASS* netclass = m_NetClasses.Find( m_CurrentNetClassName );
@@ -548,13 +514,6 @@ int BOARD::GetLayerColor( int aLayer )
}
}




/**
 * Function IsModuleLayerVisible
 * expects either of the two layers on which a module can reside, and returns
 * whether that layer is visible.
 * @param layer One of the two allowed layers for modules: LAYER_N_FRONT or LAYER_N_BACK
 * @return bool - true if the layer is visible, else false.
 */
bool BOARD::IsModuleLayerVisible( int layer )
bool BOARD::IsModuleLayerVisible( int layer )
{
{
    if( layer==LAYER_N_FRONT )
    if( layer==LAYER_N_FRONT )
@@ -621,8 +580,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
        aBoardItem->SetParent( this );
        aBoardItem->SetParent( this );


        // Because the list of pads has changed, reset the status
        // Because the list of pads has changed, reset the status
        // This indicate the list of pad and nets must be recalculated before
        // This indicate the list of pad and nets must be recalculated before use
        // use
        m_Status_Pcb = 0;
        m_Status_Pcb = 0;
        break;
        break;


@@ -654,7 +612,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )


BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem )
BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem )
{
{
    // find these calls and fix them!  Don't send me no stinkin' NULL.
    // find these calls and fix them!  Don't send me no stinking' NULL.
    wxASSERT( aBoardItem );
    wxASSERT( aBoardItem );


    switch( aBoardItem->Type() )
    switch( aBoardItem->Type() )
@@ -737,28 +695,24 @@ void BOARD::DeleteZONEOutlines()
}
}




/* Calculate the track segment count */
int BOARD::GetNumSegmTrack()
int BOARD::GetNumSegmTrack()
{
{
    return m_Track.GetCount();
    return m_Track.GetCount();
}
}




/* Calculate the zone segment count */
int BOARD::GetNumSegmZone()
int BOARD::GetNumSegmZone()
{
{
    return m_Zone.GetCount();
    return m_Zone.GetCount();
}
}




// return the unconnection count
unsigned BOARD::GetNoconnectCount()
unsigned BOARD::GetNoconnectCount()
{
{
    return m_NbNoconnect;
    return m_NbNoconnect;
}
}




// return the active pad count ( pads with a netcode > 0 )
unsigned BOARD::GetNodesCount()
unsigned BOARD::GetNodesCount()
{
{
    return m_NbNodes;
    return m_NbNodes;
@@ -858,9 +812,6 @@ bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly )




// virtual, see pcbstruct.h
// virtual, see pcbstruct.h

/* Display board statistics: pads, nets, connections.. count
 */
void BOARD::DisplayInfo( EDA_DRAW_FRAME* frame )
void BOARD::DisplayInfo( EDA_DRAW_FRAME* frame )
{
{
    wxString txt;
    wxString txt;
@@ -1005,7 +956,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
        // when created, if a track or via is connected to an existing track or
        // when created, if a track or via is connected to an existing track or
        // via, it is put in linked list after this existing track or via
        // via, it is put in linked list after this existing track or via
        // So usually, connected tracks or vias are grouped in this list
        // So usually, connected tracks or vias are grouped in this list
        // So the algorithm (used in rastnest computations) which computes the
        // So the algorithm (used in ratsnest computations) which computes the
        // track connectivity is faster (more than 100 time regarding to
        // track connectivity is faster (more than 100 time regarding to
        // a non ordered list) because when it searches for a connexion, first
        // a non ordered list) because when it searches for a connexion, first
        // it tests the near (near in term of linked list) 50 items
        // it tests the near (near in term of linked list) 50 items
@@ -1174,12 +1125,6 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
 */
 */




/**
 * Function FindNet
 * searches for a net with the given netcode.
 * @param aNetcode The netcode to search for.
 * @return NETINFO_ITEM* - the net or NULL if not found.
 */
NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const
NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const
{
{
    // the first valid netcode is 1 and the last is m_NetInfo->GetCount()-1.
    // the first valid netcode is 1 and the last is m_NetInfo->GetCount()-1.
@@ -1202,12 +1147,6 @@ NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const
}
}




/**
 * Function FindNet overlaid
 * searches for a net with the given name.
 * @param aNetname A Netname to search for.
 * @return NETINFO_ITEM* - the net or NULL if not found.
 */
NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname ) const
NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname ) const
{
{
    // the first valid netcode is 1.
    // the first valid netcode is 1.
@@ -1327,13 +1266,6 @@ static bool s_SortByNodes( const NETINFO_ITEM* a, const NETINFO_ITEM* b )
}
}




/**
 * Function ReturnSortedNetnamesList
 * @param aNames An array string to fill with net names.
 * @param aSortbyPadsCount : true = sort by active pads count, false = no sort
 * (i.e. leave the sort by net names)
 * @return int - net names count.
 */
int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount )
int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount )
{
{
    if( m_NetInfo->GetCount() == 0 )
    if( m_NetInfo->GetCount() == 0 )
@@ -1406,6 +1338,7 @@ bool BOARD::Save( FILE* aFile ) const


    // save the tracks & vias
    // save the tracks & vias
    fprintf( aFile, "$TRACK\n" );
    fprintf( aFile, "$TRACK\n" );

    for( item = m_Track; item; item = item->Next() )
    for( item = m_Track; item; item = item->Next() )
        if( !item->Save( aFile ) )
        if( !item->Save( aFile ) )
            goto out;
            goto out;
@@ -1439,10 +1372,6 @@ out:
}
}




/*
 * Function RedrawAreasOutlines
 * Redraw all areas outlines on layer aLayer ( redraw all if aLayer < 0 )
 */
void BOARD::RedrawAreasOutlines( EDA_DRAW_PANEL* panel, wxDC* aDC, int aDrawMode, int aLayer )
void BOARD::RedrawAreasOutlines( EDA_DRAW_PANEL* panel, wxDC* aDC, int aDrawMode, int aLayer )
{
{
    if( !aDC )
    if( !aDC )
@@ -1458,10 +1387,6 @@ void BOARD::RedrawAreasOutlines( EDA_DRAW_PANEL* panel, wxDC* aDC, int aDrawMode
}
}




/**
 * Function RedrawFilledAreas
 * Redraw all areas outlines on layer aLayer ( redraw all if aLayer < 0 )
 */
void BOARD::RedrawFilledAreas( EDA_DRAW_PANEL* panel, wxDC* aDC, int aDrawMode, int aLayer )
void BOARD::RedrawFilledAreas( EDA_DRAW_PANEL* panel, wxDC* aDC, int aDrawMode, int aLayer )
{
{
    if( !aDC )
    if( !aDC )
@@ -1477,18 +1402,6 @@ void BOARD::RedrawFilledAreas( EDA_DRAW_PANEL* panel, wxDC* aDC, int aDrawMode,
}
}




/**
 * Function HitTestForAnyFilledArea
 * tests if the given wxPoint is within the bounds of a filled area of this
 * zone.
 * the test is made on zones on layer from aStartLayer to aEndLayer
 * Note: if a zone has its flag BUSY (in .m_State) is set, it is ignored.
 * @param aRefPos A wxPoint to test
 * @param aStartLayer the first layer to test
 * @param aEndLayer the last layer (-1 to ignore it) to test
 * @return ZONE_CONTAINER* return a pointer to the ZONE_CONTAINER found, else
 * NULL
 */
ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
                                                int            aStartLayer,
                                                int            aStartLayer,
                                                int            aEndLayer )
                                                int            aEndLayer )
@@ -1507,8 +1420,8 @@ ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
        if( (layer < aStartLayer) || (layer > aEndLayer) )
        if( (layer < aStartLayer) || (layer > aEndLayer) )
            continue;
            continue;


        if( area->GetState( BUSY ) )      // In locate functions we must skip
        // In locate functions we must skip tagged items with BUSY flag set.
                                          // tagged items with BUSY flag set.
        if( area->GetState( BUSY ) )
            continue;
            continue;


        if( area->HitTestFilledArea( aRefPos ) )
        if( area->HitTestFilledArea( aRefPos ) )
@@ -1519,19 +1432,6 @@ ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
}
}




/**
 * Function SetAreasNetCodesFromNetNames
 * Set the .m_NetCode member of all copper areas, according to the area Net
 * Name
 * The SetNetCodesFromNetNames is an equivalent to net name, for fast
 * comparisons.
 * However the Netcode is an arbitrary equivalence, it must be set after each
 * netlist read
 * or net change
 * Must be called after pad netcodes are calculated
 * @return : error count
 * For non copper areas, netcode is set to 0
 */
int BOARD::SetAreasNetCodesFromNetNames( void )
int BOARD::SetAreasNetCodesFromNetNames( void )
{
{
    int error_count = 0;
    int error_count = 0;
@@ -1555,8 +1455,9 @@ int BOARD::SetAreasNetCodesFromNetNames( void )
            else
            else
            {
            {
                error_count++;
                error_count++;
                GetArea( ii )->SetNet( -1 );    // keep Net Name and set

                                                // m_NetCode to -1 : error flag
                // keep Net Name and set m_NetCode to -1 : error flag.
                GetArea( ii )->SetNet( -1 );
            }
            }
        }
        }
    }
    }
@@ -1565,15 +1466,34 @@ int BOARD::SetAreasNetCodesFromNetNames( void )
}
}




TRACK* BOARD::GetViaByPosition( const wxPoint& aPosition, int aLayerMask )
{
    TRACK* track;

    for( track = m_Track;  track; track = track->Next() )
    {
        if( track->Type() != TYPE_VIA )
            continue;

        if( track->m_Start != aPosition )
            continue;

        if( track->GetState( BUSY | IS_DELETED ) )
            continue;

        if( aLayerMask < 0 )
            break;

        if( track->IsOnLayer( aLayerMask ) )
            break;
    }

    return track;
}


#if defined(DEBUG)
#if defined(DEBUG)


/**
 * Function Show
 * is used to output the object tree, currently for debugging only.
 * @param nestLevel An aid to prettier tree indenting, and is the level
 *          of nesting of this object within the overall tree.
 * @param os The ostream& to output to.
 */
void BOARD::Show( int nestLevel, std::ostream& os )
void BOARD::Show( int nestLevel, std::ostream& os )
{
{
    BOARD_ITEM* p;
    BOARD_ITEM* p;
@@ -1630,9 +1550,7 @@ void BOARD::Show( int nestLevel, std::ostream& os )
        p->Show( nestLevel + 1, os );
        p->Show( nestLevel + 1, os );
    }
    }


    NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str()
    NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
                                 << ">\n";
}
}



#endif
#endif
+181 −135

File changed.

Preview size limit exceeded, changes collapsed.

+64 −113
Original line number Original line Diff line number Diff line
@@ -152,12 +152,6 @@ TRACK::TRACK( const TRACK& Source ) :
}
}




/*  Because of the way SEGVIA and SEGZONE are derived from TRACK and because there are
 *  virtual functions being used, we can no longer simply copy a TRACK and
 *  expect it to be a via or zone.  We must construct a true SEGVIA or SEGZONE so its constructor
 *  can initialize the virtual function table properly.  This factory type of
 *  function called Copy() can duplicate either a TRACK, SEGVIA, or SEGZONE.
 */
TRACK* TRACK::Copy() const
TRACK* TRACK::Copy() const
{
{
    if( Type() == TYPE_TRACK )
    if( Type() == TYPE_TRACK )
@@ -173,30 +167,14 @@ TRACK* TRACK::Copy() const
}
}




/**
 * Function GetClearance (virtual)
 * returns the clearance in internal units.  If \a aItem is not NULL then the
 * returned clearance is the greater of this object's clearance and
 * aItem's clearance.  If \a aItem is NULL, then this objects
 * clearance
 * is returned.
 * @param aItem is another BOARD_CONNECTED_ITEM or NULL
 * @return int - the clearance in internal units.
 */
int TRACK::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
int TRACK::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
{
{
    // Currently tracks have no specific clearance parameter
    // Currently tracks have no specific clearance parameter on a per track or per
    // on a per track or per segment basis.
    // segment basis.  The NETCLASS clearance is used.
    // the NETCLASS clearance is used
    return BOARD_CONNECTED_ITEM::GetClearance( aItem );
    return BOARD_CONNECTED_ITEM::GetClearance( aItem );
}
}




/**
 * Function GetDrillValue
 * calculate the drill value for vias (m_Drill if > 0, or default drill value for the Netclass
 * @return real drill_value
 */
int TRACK::GetDrillValue() const
int TRACK::GetDrillValue() const
{
{
    if( Type() != TYPE_VIA )
    if( Type() != TYPE_VIA )
@@ -215,7 +193,6 @@ int TRACK::GetDrillValue() const
}
}




// return true if segment length = 0
bool TRACK::IsNull()
bool TRACK::IsNull()
{
{
    if( ( Type() != TYPE_VIA ) && ( m_Start == m_End ) )
    if( ( Type() != TYPE_VIA ) && ( m_Start == m_End ) )
@@ -225,13 +202,6 @@ bool TRACK::IsNull()
}
}




/* Return:
 *  STARTPOINT if point if near (dist = min_dist) star point
 *  ENDPOINT  if point if near (dist = min_dist) end point
 *  STARTPOINT|ENDPOINT  if point if near (dist = min_dist) both ends
 *  0 if no
 *  if min_dist < 0: min_dist = track_width/2
 */
int TRACK::IsPointOnEnds( const wxPoint& point, int min_dist )
int TRACK::IsPointOnEnds( const wxPoint& point, int min_dist )
{
{
    int result = 0;
    int result = 0;
@@ -331,12 +301,6 @@ EDA_RECT TRACK::GetBoundingBox() const
}
}




/**
 * Function Rotate
 * Rotate this object.
 * @param aRotCentre - the rotation point.
 * @param aAngle - the rotation angle in 0.1 degree.
 */
void TRACK::Rotate( const wxPoint& aRotCentre, int aAngle )
void TRACK::Rotate( const wxPoint& aRotCentre, int aAngle )
{
{
    RotatePoint( &m_Start, aRotCentre, aAngle );
    RotatePoint( &m_Start, aRotCentre, aAngle );
@@ -344,11 +308,6 @@ void TRACK::Rotate( const wxPoint& aRotCentre, int aAngle )
}
}




/**
 * Function Flip
 * Flip this object, i.e. change the board side for this object
 * @param aCentre - the rotation point.
 */
void TRACK::Flip( const wxPoint& aCentre )
void TRACK::Flip( const wxPoint& aCentre )
{
{
    m_Start.y = aCentre.y - (m_Start.y - aCentre.y);
    m_Start.y = aCentre.y - (m_Start.y - aCentre.y);
@@ -366,7 +325,6 @@ void TRACK::Flip( const wxPoint& aCentre )




// see class_track.h
// see class_track.h
// SEGVIA and SEGZONE inherit this version
SEARCH_RESULT TRACK::Visit( INSPECTOR* inspector, const void* testData,
SEARCH_RESULT TRACK::Visit( INSPECTOR* inspector, const void* testData,
                            const KICAD_T scanTypes[] )
                            const KICAD_T scanTypes[] )
{
{
@@ -400,9 +358,6 @@ bool SEGVIA::IsOnLayer( int layer_number ) const
}
}




/* Return the mask layer for this.
 *  for a via, there is more than one layer used
 */
int TRACK::ReturnMaskLayer()
int TRACK::ReturnMaskLayer()
{
{
    if( Type() == TYPE_VIA )
    if( Type() == TYPE_VIA )
@@ -435,14 +390,6 @@ int TRACK::ReturnMaskLayer()
}
}




/** Set the .m_Layer member param:
 *  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 secaon layer
 * @param top_layer = first layer connected by the via
 * @param bottom_layer = last layer connected by the via
 */
void SEGVIA::SetLayerPair( int top_layer, int bottom_layer )
void SEGVIA::SetLayerPair( int top_layer, int bottom_layer )
{
{
    if( Shape() == VIA_THROUGH )
    if( Shape() == VIA_THROUGH )
@@ -458,13 +405,6 @@ void SEGVIA::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 SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) const
void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) const
{
{
    int b_layer = LAYER_N_BACK;
    int b_layer = LAYER_N_BACK;
@@ -506,9 +446,6 @@ TRACK* TRACK::GetBestInsertPoint( BOARD* aPcb )
}
}




/* Search (within the track linked list) the first segment matching the netcode
 * ( the linked list is always sorted by net codes )
 */
TRACK* TRACK::GetStartNetCode( int NetCode )
TRACK* TRACK::GetStartNetCode( int NetCode )
{
{
    TRACK* Track = this;
    TRACK* Track = this;
@@ -538,9 +475,6 @@ TRACK* TRACK::GetStartNetCode( int NetCode )
}
}




/* Search (within the track linked list) the last segment matching the netcode
 * ( the linked list is always sorted by net codes )
 */
TRACK* TRACK::GetEndNetCode( int NetCode )
TRACK* TRACK::GetEndNetCode( int NetCode )
{
{
    TRACK* NextS, * Track = this;
    TRACK* NextS, * Track = this;
@@ -667,6 +601,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint&
                          m_Start.y + aOffset.y, radius, m_Width, color );
                          m_Start.y + aOffset.y, radius, m_Width, color );
            }
            }
        }
        }

        return;
        return;
    }
    }


@@ -838,8 +773,9 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint
    // Draw the via hole if the display option allows it
    // Draw the via hole if the display option allows it
    if( DisplayOpt.m_DisplayViaMode != VIA_HOLE_NOT_SHOW )
    if( DisplayOpt.m_DisplayViaMode != VIA_HOLE_NOT_SHOW )
    {
    {
        if( (DisplayOpt.m_DisplayViaMode == ALL_VIA_HOLE_SHOW)          // Display all drill holes requested
        // Display all drill holes requested or Display non default holes requested
           || ( (drill_radius > 0 ) && !IsDrillDefault() ) )             // Or Display non default holes requested
        if( (DisplayOpt.m_DisplayViaMode == ALL_VIA_HOLE_SHOW)
          || ( (drill_radius > 0 ) && !IsDrillDefault() ) )
        {
        {
            if( fillvia )
            if( fillvia )
            {
            {
@@ -879,8 +815,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint
    if( DisplayOpt.ShowTrackClearanceMode == SHOW_CLEARANCE_ALWAYS )
    if( DisplayOpt.ShowTrackClearanceMode == SHOW_CLEARANCE_ALWAYS )
        GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset, radius + GetClearance(), 0, color );
        GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset, radius + GetClearance(), 0, color );


    // for Micro Vias, draw a partial cross :
    // for Micro Vias, draw a partial cross : X on component layer, or + on copper layer
    // X on component layer, or + on copper layer
    // (so we can see 2 superimposed microvias ):
    // (so we can see 2 superimposed microvias ):
    if( Shape() == VIA_MICROVIA )
    if( Shape() == VIA_MICROVIA )
    {
    {
@@ -918,8 +853,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint
                m_Start.y + aOffset.y + ax, 0, color );
                m_Start.y + aOffset.y + ax, 0, color );
    }
    }


    // for Buried Vias, draw a partial line :
    // for Buried Vias, draw a partial line : orient depending on layer pair
    // orient depending on layer pair
    // (so we can see superimposed buried vias ):
    // (so we can see superimposed buried vias ):
    if( Shape() == VIA_BLIND_BURIED )
    if( Shape() == VIA_BLIND_BURIED )
    {
    {
@@ -1026,13 +960,6 @@ void TRACK::DisplayInfo( EDA_DRAW_FRAME* frame )
}
}




/*
 * Function DisplayInfoBase
 * has knowledge about the frame and how and where to put status information
 * about this object into the frame's message panel.
 * 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.
 */
void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame )
void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame )
{
{
    wxString msg;
    wxString msg;
@@ -1071,7 +998,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame )


        frame->AppendMsgPanel( _( "NetName" ), msg, RED );
        frame->AppendMsgPanel( _( "NetName" ), msg, RED );


        /* Display net code : (usefull in test or debug) */
        /* Display net code : (useful in test or debug) */
        msg.Printf( wxT( "%d .%d" ), GetNet(), GetSubNet() );
        msg.Printf( wxT( "%d .%d" ), GetNet(), GetSubNet() );
        frame->AppendMsgPanel( _( "NetCode" ), msg, RED );
        frame->AppendMsgPanel( _( "NetCode" ), msg, RED );
    }
    }
@@ -1148,12 +1075,6 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame )
}
}




/**
 * Function HitTest
 * tests if the given wxPoint is within the bounds of this object.
 * @param refPos A wxPoint to test
 * @return bool - true if a hit, else false
 */
bool TRACK::HitTest( const wxPoint& refPos )
bool TRACK::HitTest( const wxPoint& refPos )
{
{
    int radius = m_Width >> 1;
    int radius = m_Width >> 1;
@@ -1180,13 +1101,6 @@ bool TRACK::HitTest( const wxPoint& refPos )
}
}




/**
 * Function HitTest (overlaid)
 * tests if the given EDA_RECT intersect this object.
 * For now, an ending point must be inside this rect.
 * @param refArea an EDA_RECT to test
 * @return bool - true if a hit, else false
 */
bool TRACK::HitTest( EDA_RECT& refArea )
bool TRACK::HitTest( EDA_RECT& refArea )
{
{
    if( refArea.Contains( m_Start ) )
    if( refArea.Contains( m_Start ) )
@@ -1199,6 +1113,58 @@ bool TRACK::HitTest( EDA_RECT& refArea )
}
}




TRACK* TRACK::GetVia( const wxPoint& aPosition, int aLayerMask )
{
    TRACK* track;

    for( track = this;   track;  track = track->Next() )
    {
        if( track->Type() != TYPE_VIA )
            continue;

        if( !track->HitTest( aPosition ) )
            continue;

        if( track->GetState( BUSY | IS_DELETED ) )
            continue;

        if( aLayerMask < 0 )
            break;

        if( track->IsOnLayer( aLayerMask ) )
            break;
    }

    return track;
}


TRACK* TRACK::GetVia( TRACK* aEndTrace, const wxPoint& aPosition, int aLayerMask )
{
    TRACK* trace;

    for( trace = this; trace != NULL; trace = trace->Next() )
    {
        if( trace->Type() == TYPE_VIA )
        {
            if( aPosition == trace->m_Start )
            {
                if( trace->GetState( BUSY | IS_DELETED ) == 0 )
                {
                    if( aLayerMask & trace->ReturnMaskLayer() )
                        return trace;
                }
            }
        }

        if( trace == aEndTrace )
            break;
    }

    return NULL;
}


wxString TRACK::GetSelectMenuText() const
wxString TRACK::GetSelectMenuText() const
{
{
    wxString text;
    wxString text;
@@ -1231,13 +1197,6 @@ wxString TRACK::GetSelectMenuText() const


#if defined(DEBUG)
#if defined(DEBUG)


/**
 * Function Show
 * is used to output the object tree, currently for debugging only.
 * @param nestLevel An aid to prettier tree indenting, and is the level
 *          of nesting of this object within the overall tree.
 * @param os The ostream& to output to.
 */
void TRACK::Show( int nestLevel, std::ostream& os )
void TRACK::Show( int nestLevel, std::ostream& os )
{
{
    NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
    NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
@@ -1258,13 +1217,6 @@ void TRACK::Show( int nestLevel, std::ostream& os )
}
}




/**
 * Function Show
 * is used to output the object tree, currently for debugging only.
 * @param nestLevel An aid to prettier tree indenting, and is the level
 *          of nesting of this object within the overall tree.
 * @param os The ostream& to output to.
 */
void SEGVIA::Show( int nestLevel, std::ostream& os )
void SEGVIA::Show( int nestLevel, std::ostream& os )
{
{
    const char* cp;
    const char* cp;
@@ -1355,5 +1307,4 @@ wxString TRACK::ShowState( int stateBits )
    return ret;
    return ret;
}
}



#endif
#endif
+81 −29
Original line number Original line Diff line number Diff line
/*******************************************************************/
/**
/*	class_track.h: definitions relatives to tracks, vias and zones */
 * @file class_track.h
/*******************************************************************/
 * @brief Definitions for tracks, vias and zones.
 */


#ifndef CLASS_TRACK_H
#ifndef CLASS_TRACK_H
#define CLASS_TRACK_H
#define CLASS_TRACK_H
@@ -52,6 +53,12 @@ public:
     * Function Copy
     * Function Copy
     * will copy this object whether it is a TRACK or a SEGVIA returning
     * will copy this object whether it is a TRACK or a SEGVIA returning
     * the corresponding type.
     * the corresponding type.
     * Because of the way SEGVIA and SEGZONE are derived from TRACK and because there are
     * virtual functions being used, we can no longer simply copy a TRACK and
     * expect it to be a via or zone.  We must construct a true SEGVIA or SEGZONE so its
     * constructor can initialize the virtual function table properly.  This factory type
     * of function called Copy() can duplicate either a TRACK, SEGVIA, or SEGZONE.
     *
     * @return - TRACK*, SEGVIA*, or SEGZONE*, declared as the least common
     * @return - TRACK*, SEGVIA*, or SEGZONE*, declared as the least common
     *           denominator: TRACK
     *           denominator: TRACK
     */
     */
@@ -60,7 +67,6 @@ public:
    TRACK* Next() const { return (TRACK*) Pnext; }
    TRACK* Next() const { return (TRACK*) Pnext; }
    TRACK* Back() const { return (TRACK*) Pback; }
    TRACK* Back() const { return (TRACK*) Pback; }



    /**
    /**
     * Function Move
     * Function Move
     * move this object.
     * move this object.
@@ -198,6 +204,13 @@ public:
     */
     */
    int ReturnMaskLayer();
    int ReturnMaskLayer();


    /**
     * Function IsPointOnEnds
     * returns STARTPOINT if point if near (dist = min_dist) start point, ENDPOINT if
     * point if near (dist = min_dist) end point,STARTPOINT|ENDPOINT if point if near
     * (dist = min_dist) both ends, or 0 if none of the above.
     * if min_dist < 0: min_dist = track_width/2
     */
    int IsPointOnEnds( const wxPoint& point, int min_dist = 0 );
    int IsPointOnEnds( const wxPoint& point, int min_dist = 0 );


    /**
    /**
@@ -265,6 +278,28 @@ public:
     */
     */
    bool HitTest( EDA_RECT& refArea );
    bool HitTest( EDA_RECT& refArea );


    /**
     * 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 aLayerMask The layer to match, pass -1 for a don't care.
     * @return A pointer to a SEGVIA object if found, else NULL.
     */
    TRACK* GetVia( const wxPoint& aPosition, int aLayerMask = -1 );

    /**
     * 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 aLayerMask The layers to match, pass -1 for a don't care.
     * @return A pointer to a SEGVIA object if found, else NULL.
     */
    TRACK* GetVia( TRACK* aEndTrace, const wxPoint& aPosition, int aLayerMask );

    /**
    /**
     * Function GetClass
     * Function GetClass
     * returns the class name.
     * returns the class name.
@@ -351,7 +386,6 @@ 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
     * tests to see if this object is on the given layer.  Is virtual
     * tests to see if this object is on the given layer.  Is virtual
@@ -361,7 +395,25 @@ public:
     */
     */
    bool IsOnLayer( int aLayer ) const;
    bool IsOnLayer( int aLayer ) const;


    /**
     * Function SetLayerPair
     * set the .m_Layer member param:
     *  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 secaon 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 );
    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;
    void ReturnLayerPair( int* top_layer, int* bottom_layer ) const;


    /**
    /**
Loading