Commit 42ef7f62 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

*) Start removing some of the problematic "<%s>.." format strings, which won't

   pass into an HTML rendering panel and otherwise look goofey.
*) Implement BOARD::Move() can call it from EAGLE_PLUGIN::Load().
*) When USE_FP_LIB_TABLE, tolerate blank nicknames in FPIDs coming from eeschema.
   See the switch for this in pcbnew/netlist.cpp as ALLOW_PARTIAL_FPID.
*) Add an assert and a try catch block to figure out that View does not
   like some eagle pcb board.  bitset::set() is getting a -1 value and firing
   an exception.
parent 9e61c6ce
Loading
Loading
Loading
Loading
+0 −19
Original line number Diff line number Diff line
@@ -840,22 +840,3 @@ void FP_LIB_TABLE::Load( const wxFileName& aFileName, FP_LIB_TABLE* aFallBackTab
    }
}

#if 0  // don't know that this is needed yet
MODULE* FP_LIB_TABLE::LookupFootprint( const FP_LIB_ID& aFootprintId )
    throw( IO_ERROR )
{
    const ROW* row = FindRow( aFootprintId.GetLibraryNickName() );

    // row will never be NULL here.

    PLUGIN::RELEASER pi( PluginFind( row->type ) );

    return pi->FootprintLoad(   aLibraryPath->GetFullURI() ),
                                aFootprintId.GetFootprintName(),

                                // fetch a PROPERTIES instance on stack here
                                row->GetPropertiesFromOptions()
                                );
}
#endif
+5 −0
Original line number Diff line number Diff line
@@ -367,8 +367,13 @@ protected:
        m_layers.reset();

        for( int i = 0; i < aCount; ++i )
        {
            // this fires on some eagle board after EAGLE_PLUGIN::Load()
            wxASSERT( unsigned( aLayers[i] ) <= unsigned( VIEW::VIEW_MAX_LAYERS ) );

            m_layers.set( aLayers[i] );
        }
    }
};
} // namespace KIGFX

+9 −2
Original line number Diff line number Diff line
@@ -176,7 +176,14 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
    {
        KIGFX::VIEW* view = m_galCanvas->GetView();

        try
        {
            ViewReloadBoard( m_Pcb );
        }
        catch( const std::exception& ex )
        {
            DBG(printf( "ViewReloadBoard: exception: %s\n", ex.what() );)
        }

        // update the tool manager with the new board and its view.
        if( m_toolManager )
+68 −14
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@

#include <pcbnew.h>
#include <colors_selection.h>
#include <collectors.h>

#include <class_board.h>
#include <class_module.h>
@@ -139,7 +140,39 @@ void BOARD::SetPosition( const wxPoint& aPos )

void BOARD::Move( const wxPoint& aMoveVector )        // overload
{
    wxLogWarning( wxT( "This should not be called on the BOARD object") );
    // Implement 'interface INSPECTOR' which is only INSPECTOR::Inspect(),
    // here it does the moving.
    struct MOVER : public INSPECTOR
    {
        SEARCH_RESULT Inspect( EDA_ITEM* item, const void* data )
        {
            BOARD_ITEM*     brd_item = (BOARD_ITEM*) item;
            const wxPoint*  vector   = (const wxPoint*) data;

            brd_item->Move( *vector );

            return SEARCH_CONTINUE;
        }
    } inspector;

    // @todo : anything like this elsewhere?  maybe put into GENERAL_COLLECTOR class.
    static const KICAD_T top_level_board_stuff[] = {
        PCB_MARKER_T,
        PCB_TEXT_T,
        PCB_LINE_T,
        PCB_DIMENSION_T,
        PCB_TARGET_T,
        PCB_VIA_T,
        PCB_TRACE_T,
        //        PCB_PAD_T,
        //        PCB_MODULE_TEXT_T,
        PCB_MODULE_T,
        PCB_ZONE_AREA_T,         // if it is visible on screen, it should be selectable
        EOT
    };

    // visit this BOARD with the above inspector, which moves all items.
    Visit( &inspector, &aMoveVector, top_level_board_stuff );
}


@@ -1395,10 +1428,11 @@ NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname ) const

MODULE* BOARD::FindModuleByReference( const wxString& aReference ) const
{
    struct FindModule : public INSPECTOR
    struct FINDER : public INSPECTOR
    {
        MODULE* found;
        FindModule() : found( 0 )  {}

        FINDER() : found( 0 )  {}

        // implement interface INSPECTOR
        SEARCH_RESULT Inspect( EDA_ITEM* item, const void* data )
@@ -1427,20 +1461,29 @@ MODULE* BOARD::FindModuleByReference( const wxString& aReference ) const
}


MODULE* BOARD::FindModule( const wxString& aRefOrTimeStamp, bool aSearchByTimeStamp )
{
    for( MODULE* module = m_Modules;  module != NULL;  module = module->Next() )
MODULE* BOARD::FindModule( const wxString& aRefOrTimeStamp, bool aSearchByTimeStamp ) const
{
    if( aSearchByTimeStamp )
    {
        for( MODULE* module = m_Modules;  module;  module = module->Next() )
        {
            if( aRefOrTimeStamp.CmpNoCase( module->GetPath() ) == 0 )
                return module;
        }
    }
    else
    {

#if 0   // case independent compare, why?
        for( MODULE* module = m_Modules;  module;  module = module->Next() )
        {
            if( aRefOrTimeStamp.CmpNoCase( module->GetReference() ) == 0 )
                return module;
        }
#else
        return FindModuleByReference( aRefOrTimeStamp );
#endif

    }

    return NULL;
@@ -2388,6 +2431,14 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,

        if( aReporter && aReporter->ReportAll() )
        {
#if defined(DEBUG)
            if( component->GetReference() == wxT( "D2" ) )
            {
                int breakhere = 1;
                (void) breakhere;
            }
#endif

            msg.Printf( _( "Checking netlist component footprint \"%s:%s:%s\".\n" ),
                        GetChars( component->GetReference() ),
                        GetChars( component->GetTimeStamp() ),
@@ -2626,12 +2677,15 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
    if( aDeleteSinglePadNets && !aNetlist.IsDryRun() )
    {
        BuildListOfNets();

        std::vector<D_PAD*> padlist = GetPads();

        // padlist is the list of pads, sorted by netname.
        int         count = 0;
        wxString    netname;
        D_PAD*      pad = NULL;
        D_PAD*      previouspad = NULL;

        for( unsigned ii = 0; ii < padlist.size(); ii++ )
        {
            pad = padlist[ii];
@@ -2645,7 +2699,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
                {
                    if( aReporter && aReporter->ReportAll() )
                    {
                        msg.Printf( _( "Remove single pad net \"%s\" on \"%s\" pad <%s>\n" ),
                        msg.Printf( _( "Remove single pad net \"%s\" on \"%s\" pad '%s'\n" ),
                                    GetChars( previouspad->GetNetname() ),
                                    GetChars( previouspad->GetParent()->GetReference() ),
                                    GetChars( previouspad->GetPadName() ) );
@@ -2693,7 +2747,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
                    continue;   // OK, pad found

                // not found: bad footprint, report error
                msg.Printf( _( "** Error: Component \"%s\" pad <%s> not found in footprint \"%s\" **\n" ),
                msg.Printf( _( "** Error: Component \"%s\" pad '%s' not found in footprint \"%s\" **\n" ),
                            GetChars( component->GetReference() ),
                            GetChars( padname ),
                            footprint->GetFPID().Format().c_str() );
@@ -2718,7 +2772,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
            // Net name not valid, report error
            wxString coord;
            coord << zone->GetPosition();
            msg.Printf( _( "** Error: Zone %s layer <%s>"
            msg.Printf( _( "** Error: Zone '%s' layer '%s'"
                           " has non-existent net name \"%s\" **\n" ),
                        GetChars( coord ),
                        GetChars( zone->GetLayerName() ),
+2 −2
Original line number Diff line number Diff line
@@ -919,9 +919,9 @@ public:
     * @param aRefOrTimeStamp is the search string.
     * @param aSearchByTimeStamp searches by the module time stamp value if true.  Otherwise
     *                           search by reference designator.
     * @return the module found or NULL if not module is found that meets the search criteria.
     * @return MODULE* - If found, the module meeting the search criteria, else NULL.
     */
    MODULE* FindModule( const wxString& aRefOrTimeStamp, bool aSearchByTimeStamp = false );
    MODULE* FindModule( const wxString& aRefOrTimeStamp, bool aSearchByTimeStamp = false ) const;

    /**
     * Function ReplaceNetlist
Loading