Commit d96039a1 authored by stambaughw's avatar stambaughw
Browse files

Change search path order, wxDC zoom updates, and code clean ups.

Add helpers for inserting paths to and removing paths from search list.
Moved user defined path before default library paths in search list.
Renamed m_Draw_Auxiliary_Axis to DrawAuxiliaryAxis.
Changed parameter to fix wxDC set mode from FALSE to GR_COPY.
Minor wxDC zoom improvements.
parent a98c2415
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -573,6 +573,7 @@ int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC )
void WinEDA_DrawFrame::AdjustScrollBars()
/*********************************************/
{
#ifndef WX_ZOOM
    int     xUnit, yUnit;
    wxSize  draw_size, panel_size;
    wxSize  scrollbar_number;
@@ -652,6 +653,7 @@ void WinEDA_DrawFrame::AdjustScrollBars()
                              screen->m_ScrollbarNumber.y,
                              screen->m_ScrollbarPos.x,
                              screen->m_ScrollbarPos.y, TRUE );
#endif
}


+25 −20
Original line number Diff line number Diff line
@@ -201,9 +201,14 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC )
    wxPoint origin = GetScreen()->m_DrawOrg;
    wxLogDebug( wxT( "DC user scale factor: %0.3f, X origin: %d, Y " \
                     "origin: %d" ), scale, origin.x, origin.y );
    DoPrepareDC( *DC );
    DC->SetUserScale( scale, scale );
    DC->SetLogicalOrigin( origin.x, origin.y );
    DoPrepareDC( *DC );

    int x, y;
    wxPoint logicalPos = GetScreen()->m_Curseur - origin;;
    CalcScrolledPosition( logicalPos.x, logicalPos.y, &x, &y );
    Scroll( x, y );
#endif
    SetBoundaryBox();
}
@@ -596,9 +601,10 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
#endif

#ifdef WX_ZOOM
    BASE_SCREEN* screen = GetScreen();
    screen->Unscale( m_ClipBox.m_Pos );
    screen->Unscale( m_ClipBox.m_Size );
    m_ClipBox.m_Pos.x = paintDC.DeviceToLogicalX( m_ClipBox.m_Pos.x );
    m_ClipBox.m_Pos.y = paintDC.DeviceToLogicalY( m_ClipBox.m_Pos.y );
    m_ClipBox.m_Size.SetWidth( paintDC.DeviceToLogicalXRel( m_ClipBox.m_Size.GetWidth() ) );
    m_ClipBox.m_Size.SetHeight( paintDC.DeviceToLogicalXRel( m_ClipBox.m_Size.GetHeight() ) );
#else
    PaintClipBox.Offset( org );
    m_ClipBox.SetX( PaintClipBox.GetX() );
@@ -627,7 +633,7 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
    {
        wxDCClipper dcclip( paintDC, PaintClipBox );

        ReDraw( &paintDC, TRUE );
        ReDraw( &paintDC, true );
    }

    m_ClipBox = tmp;
@@ -658,11 +664,6 @@ void WinEDA_DrawPanel::ReDraw( wxDC* DC, bool erasebg )
        g_GhostColor = WHITE;
    }

#ifdef WX_ZOOM
    double scale = Screen->GetScalingFactor( );
    DC->SetUserScale( scale, scale );
#endif

    if( erasebg )
        PrepareGraphicContext( DC );

@@ -742,6 +743,13 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
    size = GetClientSize();
    screen->Unscale( size );

#ifdef WX_ZOOM
    org.x = DC->DeviceToLogicalX( org.x );
    org.y = DC->DeviceToLogicalY( org.y );
    size.SetWidth( DC->DeviceToLogicalXRel( size.GetWidth() ) );
    size.SetHeight( DC->DeviceToLogicalXRel( size.GetHeight() ) );
#endif

    if( drawgrid )
    {
        m_Parent->PutOnGrid( &org );
@@ -778,16 +786,12 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
                      screen->ReturnPageSize().x, 0, 0, Color );
    }

    /* Draw auxiliary axis */
    if( m_Parent->m_Draw_Auxiliary_Axis )
    {
        m_Draw_Auxiliary_Axis( DC, FALSE );
    }
    DrawAuxiliaryAxis( DC, GR_COPY );
}


/********************************************************************/
void WinEDA_DrawPanel::m_Draw_Auxiliary_Axis( wxDC* DC, int drawmode )
void WinEDA_DrawPanel::DrawAuxiliaryAxis( wxDC* DC, int drawmode )
/********************************************************************/

/** m_Draw_Auxiliary_Axis
@@ -795,8 +799,9 @@ void WinEDA_DrawPanel::m_Draw_Auxiliary_Axis( wxDC* DC, int drawmode )
 * for gerber and excellon files
 */
{
    if( m_Parent->m_Auxiliary_Axis_Position.x == 0
        && m_Parent->m_Auxiliary_Axis_Position.y == 0 )
    if( !m_Parent->m_Draw_Auxiliary_Axis
        || ( m_Parent->m_Auxiliary_Axis_Position.x == 0
             && m_Parent->m_Auxiliary_Axis_Position.y == 0 ) )
        return;

    int          Color  = DARKRED;
+32 −1
Original line number Diff line number Diff line
@@ -1023,7 +1023,38 @@ wxString WinEDA_App::FindLibraryPath( const wxString& fileName )
    if( wxFileName::FileExists( fileName ) )
        return fileName;
    else
        return GetLibraryPathList().FindValidPath( fileName );
        return m_libSearchPaths.FindValidPath( fileName );
}

void WinEDA_App::RemoveLibraryPath( const wxString& path )
{
    if( m_libSearchPaths.Index( path, wxFileName::IsCaseSensitive() ) != wxNOT_FOUND )
    {
        wxLogDebug( wxT( "Removing path <%s> from library path search list." ),
                    path.c_str() );
        m_libSearchPaths.Remove( path );
    }
}

void WinEDA_App::InsertLibraryPath( const wxString& path, size_t index )
{
    if( wxFileName::DirExists( path )
        && m_libSearchPaths.Index( path, wxFileName::IsCaseSensitive() ) == wxNOT_FOUND )
    {
        if( index >= m_libSearchPaths.GetCount() )
        {
            wxLogDebug( wxT( "Adding path <%s> to library path search list." ),
                        path.c_str() );
            m_libSearchPaths.Add( path );
        }
        else
        {
            wxLogDebug( wxT( "Inserting path <%s> in library path search " \
                             "list at index position %d." ),
                        path.c_str(), index );
            m_libSearchPaths.Insert( path, index );
        }
    }
}


+2 −4
Original line number Diff line number Diff line
@@ -60,10 +60,8 @@ bool WinEDA_App::ReCreatePrjConfig( const wxString& fileName,
    /* Update the library search path list if a new project file is loaded. */
    if( m_projectFileName != fn )
    {
        if( m_libSearchPaths.Index( fn.GetPath() ) != wxNOT_FOUND )
            m_libSearchPaths.Remove( fn.GetPath() );

        m_libSearchPaths.Insert( fn.GetPath(), 0 );
        RemoveLibraryPath( m_projectFileName.GetPath() );
        InsertLibraryPath( fn.GetPath(), 0 );
        m_projectFileName = fn;
    }

+3 −13
Original line number Diff line number Diff line
@@ -39,12 +39,7 @@ void Read_Config( const wxString& FileName )
    if( fn.GetExt() != ProjectFileExtension )
        fn.SetExt( ProjectFileExtension );

    if( wxGetApp().GetLibraryPathList().Index( g_UserLibDirBuffer ) != wxNOT_FOUND )
    {
        wxLogDebug( wxT( "Removing path <%s> to library path search list." ),
                    g_UserLibDirBuffer.c_str() );
        wxGetApp().GetLibraryPathList().Remove( g_UserLibDirBuffer );
    }
    wxGetApp().RemoveLibraryPath( g_UserLibDirBuffer );

    wxGetApp().ReadProjectConfig( fn.GetFullPath(),
                                  GROUP, ParamCfgList, FALSE );
@@ -52,13 +47,8 @@ void Read_Config( const wxString& FileName )
    if( g_NetlistFileExtension.IsEmpty() )
        g_NetlistFileExtension = wxT( "net" );

    if( wxFileName::DirExists( g_UserLibDirBuffer )
        && wxGetApp().GetLibraryPathList().Index( g_UserLibDirBuffer ) == wxNOT_FOUND )
    {
        wxLogDebug( wxT( "Adding path <%s> to library path search list." ),
                    g_UserLibDirBuffer.c_str() );
        wxGetApp().GetLibraryPathList().Add( g_UserLibDirBuffer );
    }
    /* User library path takes precedent over default library search paths. */
    wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 );
}


Loading