Commit dfb88c64 authored by stambaughw's avatar stambaughw
Browse files

Library search path fixes, library configuration dialog fixes, and code cleaning.

Added application method to fix searching for user libraries.
Fixed documentation search path bug.
Moved auto pan setting from draw frame to draw panel were it is defined.
Some minor device context drawing changes.
parent cf752a58
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -38,7 +38,7 @@ int S3D_MASTER:: ReadData()


    if( !fn.FileExists() )
    if( !fn.FileExists() )
    {
    {
        tmp = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullPath() );
        tmp = wxGetApp().FindLibraryPath( fn );


        if( !tmp )
        if( !tmp )
        {
        {
+5 −9
Original line number Original line Diff line number Diff line
@@ -55,8 +55,7 @@ BASE_SCREEN::~BASE_SCREEN()




/*******************************/
/*******************************/
void
void BASE_SCREEN::InitDatas()
BASE_SCREEN::InitDatas()
/*******************************/
/*******************************/
{
{
    if( m_Center )
    if( m_Center )
@@ -89,15 +88,13 @@ BASE_SCREEN::InitDatas()
 * internal units used by the schematic screen is 1 mil (0.001").  Override
 * internal units used by the schematic screen is 1 mil (0.001").  Override
 * this in derived classes that require internal units other than 1 mil.
 * this in derived classes that require internal units other than 1 mil.
 */
 */
int
int BASE_SCREEN::GetInternalUnits( void )
BASE_SCREEN::GetInternalUnits( void )
{
{
    return EESCHEMA_INTERNAL_UNIT;
    return EESCHEMA_INTERNAL_UNIT;
}
}


/************************************/
/************************************/
wxSize
wxSize BASE_SCREEN::ReturnPageSize( void )
BASE_SCREEN::ReturnPageSize( void )
/************************************/
/************************************/
{
{
    int internal_units = GetInternalUnits();
    int internal_units = GetInternalUnits();
@@ -113,8 +110,7 @@ BASE_SCREEN::ReturnPageSize( void )
 * @param ScreenPos = the screen (in pixel) position co convert
 * @param ScreenPos = the screen (in pixel) position co convert
*/
*/
/******************************************************************/
/******************************************************************/
wxPoint
wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos )
BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos )
/******************************************************************/
/******************************************************************/
{
{
    wxPoint curpos = ScreenPos;
    wxPoint curpos = ScreenPos;
+0 −3
Original line number Original line Diff line number Diff line
@@ -109,9 +109,6 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
WinEDA_DrawFrame::~WinEDA_DrawFrame()
WinEDA_DrawFrame::~WinEDA_DrawFrame()
/****************************************/
/****************************************/
{
{
    if( DrawPanel )  // Required: in WinEDA3D_DrawFrame, DrawPanel == NULL !
        wxGetApp().m_EDA_Config->Write( wxT( "AutoPAN" ),
                                    DrawPanel->m_AutoPAN_Enable );
}
}




+15 −3
Original line number Original line Diff line number Diff line
@@ -73,7 +73,8 @@ WinEDA_DrawPanel::WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id,
    ForceCloseManageCurseur = NULL;
    ForceCloseManageCurseur = NULL;


    if( wxGetApp().m_EDA_Config )
    if( wxGetApp().m_EDA_Config )
        m_AutoPAN_Enable = wxGetApp().m_EDA_Config->Read( wxT( "AutoPAN" ), true );
        m_AutoPAN_Enable = wxGetApp().m_EDA_Config->Read( wxT( "AutoPAN" ),
                                                          true );


    m_AutoPAN_Request    = FALSE;
    m_AutoPAN_Request    = FALSE;
    m_Block_Enable       = FALSE;
    m_Block_Enable       = FALSE;
@@ -83,6 +84,14 @@ WinEDA_DrawPanel::WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id,
}
}




WinEDA_DrawPanel::~WinEDA_DrawPanel()
{
    wxASSERT( wxGetApp().m_EDA_Config != NULL );

    wxGetApp().m_EDA_Config->Write( wxT( "AutoPAN" ), m_AutoPAN_Enable );
}


BASE_SCREEN* WinEDA_DrawPanel::GetScreen()
BASE_SCREEN* WinEDA_DrawPanel::GetScreen()
{
{
    WinEDA_DrawFrame* parentFrame = m_Parent;
    WinEDA_DrawFrame* parentFrame = m_Parent;
@@ -189,7 +198,11 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC )
    DC->SetBackgroundMode( wxTRANSPARENT );
    DC->SetBackgroundMode( wxTRANSPARENT );
#ifdef WX_ZOOM
#ifdef WX_ZOOM
    double scale = GetScreen()->GetScalingFactor( );
    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 );
    DC->SetUserScale( scale, scale );
    DC->SetUserScale( scale, scale );
    DC->SetLogicalOrigin( origin.x, origin.y );
    DoPrepareDC( *DC );
    DoPrepareDC( *DC );
#endif
#endif
    SetBoundaryBox();
    SetBoundaryBox();
@@ -582,13 +595,12 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
            );
            );
#endif
#endif


    PaintClipBox.Offset( org );

#ifdef WX_ZOOM
#ifdef WX_ZOOM
    BASE_SCREEN* screen = GetScreen();
    BASE_SCREEN* screen = GetScreen();
    screen->Unscale( m_ClipBox.m_Pos );
    screen->Unscale( m_ClipBox.m_Pos );
    screen->Unscale( m_ClipBox.m_Size );
    screen->Unscale( m_ClipBox.m_Size );
#else
#else
    PaintClipBox.Offset( org );
    m_ClipBox.SetX( PaintClipBox.GetX() );
    m_ClipBox.SetX( PaintClipBox.GetX() );
    m_ClipBox.SetY( PaintClipBox.GetY() );
    m_ClipBox.SetY( PaintClipBox.GetY() );
    m_ClipBox.SetWidth( PaintClipBox.GetWidth() );
    m_ClipBox.SetWidth( PaintClipBox.GetWidth() );
+19 −1
Original line number Original line Diff line number Diff line
@@ -541,14 +541,15 @@ void WinEDA_App::SetDefaultSearchPaths( void )
            }
            }


            /* Add schematic doc file path (library/doc)to search path list. */
            /* Add schematic doc file path (library/doc)to search path list. */
            fn.RemoveLastDir();
            fn.AppendDir( wxT( "doc") );
            fn.AppendDir( wxT( "doc") );

            if( fn.IsDirReadable() )
            if( fn.IsDirReadable() )
            {
            {
                wxLogDebug( wxT( "Adding <%s> to library search path list" ),
                wxLogDebug( wxT( "Adding <%s> to library search path list" ),
                            fn.GetPath().c_str() );
                            fn.GetPath().c_str() );
                m_libSearchPaths.Add( fn.GetPath() );
                m_libSearchPaths.Add( fn.GetPath() );
            }
            }
            fn.RemoveLastDir();


            /* Add kicad template file path to search path list. */
            /* Add kicad template file path to search path list. */
            fn.RemoveLastDir();
            fn.RemoveLastDir();
@@ -1009,6 +1010,23 @@ wxString WinEDA_App::GetLibraryFile( const wxString& filename )
}
}




/**
 * Kicad saves user defined library files that are not in the standard
 * library search path list with the full file path.  Calling the library
 * search path list with a user library file will fail.  This helper method
 * solves that problem.
 *
 * Returns a wxEmptyString if library file is not found.
 */
wxString WinEDA_App::FindLibraryPath( const wxString& fileName )
{
    if( wxFileName::FileExists( fileName ) )
        return fileName;
    else
        return GetLibraryPathList().FindValidPath( fileName );
}


/**
/**
 * Run Python scripts
 * Run Python scripts
 *
 *
Loading