Commit c2b600ce authored by stambaughw's avatar stambaughw
Browse files

Replace wxList with boost::ptr_vector and fix automatic association bug in CVPCB.

* ALL: More changes for wxDC based zooming.
* 3D_VIEWER: Wrap 3d_viewer.h to prevent redefinitions.
* CVPcb: Replace wxList with boost::ptr_vector and take advantage of boost::foreach.
* CVPcb: Fix automatic association bug.
* CVPcb: Rename some variables for clarity and some minor code clean ups.
* CVPcb: Fix GTK sizing issue in library and path dialog.
* EESchema: Remove left over sizer from last commit from library and path dialog.
parent 7988f2ca
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
/////////////////////////////////////////////////////////////////////////////
// Name:        3d_viewer.h
/////////////////////////////////////////////////////////////////////////////

#ifndef __3D_VIEWER_H__
#define __3D_VIEWER_H__

#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
#endif
@@ -172,3 +176,5 @@ extern double g_Draw3d_dx, g_Draw3d_dy;
extern double ZBottom, ZTop;
extern double DataScale3D;  // coeff de conversion unites utilsateut -> unites 3D
extern int gl_attrib[];

#endif  /*  __3D_VIEWER_H__ */
+2 −2
Original line number Diff line number Diff line
@@ -116,9 +116,9 @@ wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos )
    wxPoint curpos = ScreenPos;
    Unscale( curpos );

#ifndef WX_ZOOM
//#ifndef WX_ZOOM
    curpos += m_DrawOrg;
#endif
//#endif

    return curpos;
}
+9 −2
Original line number Diff line number Diff line
@@ -590,8 +590,15 @@ void WinEDA_DrawFrame::AdjustScrollBars()
#else
    BASE_SCREEN* screen = GetBaseScreen();
    wxSize drawingSize = screen->ReturnPageSize() * 2;
    DrawPanel->SetScrollbars( 1, 1, drawingSize.x, drawingSize.y,
                              screen->m_Curseur.x, screen->m_Curseur.y, true );
    wxCoord x, y;
    wxClientDC DC( this );
    DrawPanel->PrepareGraphicContext( &DC );
    x = DC.LogicalToDeviceXRel( drawingSize.GetWidth() );
    y = DC.LogicalToDeviceYRel( drawingSize.GetHeight() );
    DrawPanel->SetScrollbars( 1, 1, x, y,
                              DC.LogicalToDeviceX( screen->m_Curseur.x ),
                              DC.LogicalToDeviceY( screen->m_Curseur.y ),
                              true );
#endif
}

+8 −11
Original line number Diff line number Diff line
@@ -199,14 +199,12 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC )
#ifdef WX_ZOOM
    double scale = GetScreen()->GetScalingFactor();
    wxPoint origin = GetScreen()->m_DrawOrg;
    wxLogDebug( wxT( "DC user scale factor: %0.3f, X origin: %d, Y " \
                     "origin: %d" ), scale, origin.x, origin.y );
    int ppuX, ppuY, startX, startY;
    GetScrollPixelsPerUnit( & ppuX, & ppuY );
    GetViewStart( &startX, &startY );
    DC->SetDeviceOrigin( origin.x - startX * ppuX, origin.y - startY * ppuY );
    DC->SetUserScale( scale, scale );
    wxSize size = GetScreen()->ReturnPageSize() * 2 * scale;
//    wxSize size = GetScreen()->ReturnPageSize() * 2 * scale;
//    DC->SetLogicalOrigin( origin.x, origin.y );
#endif
    SetBoundaryBox();
@@ -368,12 +366,11 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void )

    GetScreen()->Unscale( realpos );
#ifdef WX_ZOOM
    wxCoord x, y;
    wxClientDC DC( this );
    PrepareGraphicContext( &DC );
    x = DC.DeviceToLogicalX( realpos.x );
    y = DC.DeviceToLogicalY( realpos.y );
    return wxPoint( x, y );
//    wxCoord x, y;
//    wxClientDC DC( this );
//    PrepareGraphicContext( &DC );
//    realpos.x = DC.DeviceToLogicalX( realpos.x );
//    realpos.y = DC.DeviceToLogicalY( realpos.y );
#else
    realpos += GetScreen()->m_DrawOrg;
#endif
+58 −62
Original line number Diff line number Diff line
@@ -15,19 +15,21 @@
#include "protos.h"
#include "cvstruct.h"


#define QUOTE '\''

class AUTOMODULE
class FOOTPRINT_ALIAS
{
public:
    int         m_Type;
    AUTOMODULE* Pnext;
    wxString    m_Name;
    wxString    m_LibName;
    wxString    m_FootprintName;

    AUTOMODULE() { m_Type = 0; Pnext = NULL; }
    FOOTPRINT_ALIAS() { m_Type = 0; }
};

typedef boost::ptr_vector< FOOTPRINT_ALIAS > FOOTPRINT_ALIAS_LIST;


/*
 * read the string between quotes and put it in aTarget
@@ -68,18 +70,13 @@ char * ReadQuotedText(wxString & aTarget, char * aText)
 */
void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
{
    COMPONENT_LIST::iterator iCmp;
    FOOTPRINT_LIST::iterator iFp;
    FOOTPRINT_ALIAS_LIST aliases;
    FOOTPRINT_ALIAS*     alias;
    wxFileName           fn;
    wxString             msg, tmp;
    char                 Line[1024];
    FILE*                file;
    AUTOMODULE* ItemModule, * NextMod;
    AUTOMODULE* BaseListeMod = NULL;
    COMPONENT*  Component;
    FOOTPRINT*  footprint;
    size_t               ii;
    int         nb_correspondances = 0;

    if( m_components.empty() )
        return;
@@ -89,7 +86,6 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
    {
        fn = m_AliasLibNames[ii];
        fn.SetExt( FootprintAliasFileExtension );

        tmp = wxGetApp().FindLibraryPath( fn );

        if( !tmp )
@@ -101,6 +97,8 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
            continue;
        }

        wxLogDebug( wxT( "Opening footprint alias file: %s." ), tmp.c_str() );

        file = wxFopen( tmp, wxT( "rt" ) );

        if( file == NULL )
@@ -114,71 +112,69 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
        while( GetLine( file, Line, NULL, sizeof(Line) ) != NULL )
        {
            char* text = Line;
            text = ReadQuotedText(tmp, text);
            wxString value, footprint;

            text = ReadQuotedText( value, text );

            if ( text == NULL || (*text == 0 )  )
            if( text == NULL || ( *text == 0 ) || value.IsEmpty() )
                continue;

            ItemModule = new AUTOMODULE();
            ItemModule->Pnext = BaseListeMod;
            BaseListeMod = ItemModule;
            text++;
            text = ReadQuotedText( footprint, text );

            /* stockage du composant ( 'namecmp'  'namelib')
             *  name et namelib */
            ItemModule->m_Name = tmp;
            if( footprint.IsEmpty() )
                continue;

            alias = new FOOTPRINT_ALIAS();
            alias->m_Name = value;
            alias->m_FootprintName = footprint;
            wxLogDebug( wxT( "Adding alias %s for footprint %s" ),
                        value.c_str(), footprint.c_str() );
            aliases.push_back( alias );
            text++;
            ReadQuotedText(ItemModule->m_LibName, text);

            nb_correspondances++;
        }

        fclose( file );
    }

    /* display some info */
    msg.Printf( _( "%d equivalences" ), nb_correspondances );
    /* Display the number of footpint aliases.  */
    msg.Printf( _( "%d footprint aliases found." ), aliases.size() );
    SetStatusText( msg, 0 );
    wxMessageBox(msg);

    for( iCmp = m_components.begin(); iCmp != m_components.end(); ++iCmp )
    {
        Component = *iCmp;
        m_ListCmp->SetSelection( m_components.IndexOf( Component ), TRUE );
    ii = 0;

        if( Component->m_Module.IsEmpty() )
    BOOST_FOREACH( COMPONENT& component, m_components )
    {
            ItemModule = BaseListeMod;
            for( ; ItemModule != NULL; ItemModule = ItemModule->Pnext )
            {
                if( ItemModule->m_Name.CmpNoCase( Component->m_Valeur ) != 0 )
        m_ListCmp->SetSelection( ii, true );

        if( !component.m_Module.IsEmpty() )
            continue;

                for( iFp = m_footprints.begin(); iFp != m_footprints.end(); ++iFp )
        BOOST_FOREACH( FOOTPRINT_ALIAS& alias, aliases )
        {
                    footprint = *iFp;
            if( alias.m_Name.CmpNoCase( component.m_Value ) != 0 )
                continue;

                    if( ItemModule->m_LibName.CmpNoCase( footprint->m_Module ) == 0 )
            BOOST_FOREACH( FOOTPRINT& footprint, m_footprints )
            {
                if( alias.m_FootprintName.CmpNoCase( footprint.m_Module ) == 0 )
                {
                        SetNewPkg( footprint->m_Module );
                    SetNewPkg( footprint.m_Module );
                    break;
                }
            }

                msg.Printf( _( "Component %s: Footprint %s not found in " \
                               "libraries" ), Component->m_Valeur.GetData(),
                            ItemModule->m_LibName.GetData() );
                DisplayError( this, msg, 10 );
            }
            if( component.m_Module.IsEmpty() )
            {
                msg.Printf( _( "Component %s: footprint %s not found in " \
                               "any of the project footprint libraries." ),
                            component.m_Reference.c_str(),
                            alias.m_FootprintName.c_str() );
                wxMessageBox( msg, _( "CVPcb Error" ), wxOK | wxICON_ERROR,
                              this );
            }
        }

    /* free memory: */
    for( ItemModule = BaseListeMod; ItemModule != NULL; ItemModule = NextMod )
    {
        NextMod = ItemModule->Pnext;
        delete ItemModule;
        ii += 1;
    }

    BaseListeMod = NULL;
}
Loading