Commit d96039a1 authored by stambaughw's avatar stambaughw

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
...@@ -573,6 +573,7 @@ int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC ) ...@@ -573,6 +573,7 @@ int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC )
void WinEDA_DrawFrame::AdjustScrollBars() void WinEDA_DrawFrame::AdjustScrollBars()
/*********************************************/ /*********************************************/
{ {
#ifndef WX_ZOOM
int xUnit, yUnit; int xUnit, yUnit;
wxSize draw_size, panel_size; wxSize draw_size, panel_size;
wxSize scrollbar_number; wxSize scrollbar_number;
...@@ -652,6 +653,7 @@ void WinEDA_DrawFrame::AdjustScrollBars() ...@@ -652,6 +653,7 @@ void WinEDA_DrawFrame::AdjustScrollBars()
screen->m_ScrollbarNumber.y, screen->m_ScrollbarNumber.y,
screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.x,
screen->m_ScrollbarPos.y, TRUE ); screen->m_ScrollbarPos.y, TRUE );
#endif
} }
......
...@@ -197,13 +197,18 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC ) ...@@ -197,13 +197,18 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC )
GRResetPenAndBrush( DC ); GRResetPenAndBrush( 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; wxPoint origin = GetScreen()->m_DrawOrg;
wxLogDebug( wxT( "DC user scale factor: %0.3f, X origin: %d, Y " \ wxLogDebug( wxT( "DC user scale factor: %0.3f, X origin: %d, Y " \
"origin: %d" ), scale, origin.x, origin.y ); "origin: %d" ), scale, origin.x, origin.y );
DoPrepareDC( *DC );
DC->SetUserScale( scale, scale ); DC->SetUserScale( scale, scale );
DC->SetLogicalOrigin( origin.x, origin.y ); 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 #endif
SetBoundaryBox(); SetBoundaryBox();
} }
...@@ -596,9 +601,10 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) ...@@ -596,9 +601,10 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
#endif #endif
#ifdef WX_ZOOM #ifdef WX_ZOOM
BASE_SCREEN* screen = GetScreen(); m_ClipBox.m_Pos.x = paintDC.DeviceToLogicalX( m_ClipBox.m_Pos.x );
screen->Unscale( m_ClipBox.m_Pos ); m_ClipBox.m_Pos.y = paintDC.DeviceToLogicalY( m_ClipBox.m_Pos.y );
screen->Unscale( m_ClipBox.m_Size ); 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 #else
PaintClipBox.Offset( org ); PaintClipBox.Offset( org );
m_ClipBox.SetX( PaintClipBox.GetX() ); m_ClipBox.SetX( PaintClipBox.GetX() );
...@@ -627,7 +633,7 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) ...@@ -627,7 +633,7 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
{ {
wxDCClipper dcclip( paintDC, PaintClipBox ); wxDCClipper dcclip( paintDC, PaintClipBox );
ReDraw( &paintDC, TRUE ); ReDraw( &paintDC, true );
} }
m_ClipBox = tmp; m_ClipBox = tmp;
...@@ -658,11 +664,6 @@ void WinEDA_DrawPanel::ReDraw( wxDC* DC, bool erasebg ) ...@@ -658,11 +664,6 @@ void WinEDA_DrawPanel::ReDraw( wxDC* DC, bool erasebg )
g_GhostColor = WHITE; g_GhostColor = WHITE;
} }
#ifdef WX_ZOOM
double scale = Screen->GetScalingFactor( );
DC->SetUserScale( scale, scale );
#endif
if( erasebg ) if( erasebg )
PrepareGraphicContext( DC ); PrepareGraphicContext( DC );
...@@ -742,6 +743,13 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC ) ...@@ -742,6 +743,13 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
size = GetClientSize(); size = GetClientSize();
screen->Unscale( size ); 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 ) if( drawgrid )
{ {
m_Parent->PutOnGrid( &org ); m_Parent->PutOnGrid( &org );
...@@ -767,7 +775,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC ) ...@@ -767,7 +775,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
} }
/* Draw axis */ /* Draw axis */
if( m_Parent->m_Draw_Axis ) if( m_Parent->m_Draw_Axis )
{ {
/* Draw the Y axis */ /* Draw the Y axis */
GRDashedLine( &m_ClipBox, DC, 0, -screen->ReturnPageSize().y, GRDashedLine( &m_ClipBox, DC, 0, -screen->ReturnPageSize().y,
...@@ -778,16 +786,12 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC ) ...@@ -778,16 +786,12 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
screen->ReturnPageSize().x, 0, 0, Color ); screen->ReturnPageSize().x, 0, 0, Color );
} }
/* Draw auxiliary axis */ DrawAuxiliaryAxis( DC, GR_COPY );
if( m_Parent->m_Draw_Auxiliary_Axis )
{
m_Draw_Auxiliary_Axis( DC, FALSE );
}
} }
/********************************************************************/ /********************************************************************/
void WinEDA_DrawPanel::m_Draw_Auxiliary_Axis( wxDC* DC, int drawmode ) void WinEDA_DrawPanel::DrawAuxiliaryAxis( wxDC* DC, int drawmode )
/********************************************************************/ /********************************************************************/
/** m_Draw_Auxiliary_Axis /** m_Draw_Auxiliary_Axis
...@@ -795,8 +799,9 @@ void WinEDA_DrawPanel::m_Draw_Auxiliary_Axis( wxDC* DC, int drawmode ) ...@@ -795,8 +799,9 @@ void WinEDA_DrawPanel::m_Draw_Auxiliary_Axis( wxDC* DC, int drawmode )
* for gerber and excellon files * for gerber and excellon files
*/ */
{ {
if( m_Parent->m_Auxiliary_Axis_Position.x == 0 if( !m_Parent->m_Draw_Auxiliary_Axis
&& m_Parent->m_Auxiliary_Axis_Position.y == 0 ) || ( m_Parent->m_Auxiliary_Axis_Position.x == 0
&& m_Parent->m_Auxiliary_Axis_Position.y == 0 ) )
return; return;
int Color = DARKRED; int Color = DARKRED;
......
...@@ -1023,7 +1023,38 @@ wxString WinEDA_App::FindLibraryPath( const wxString& fileName ) ...@@ -1023,7 +1023,38 @@ wxString WinEDA_App::FindLibraryPath( const wxString& fileName )
if( wxFileName::FileExists( fileName ) ) if( wxFileName::FileExists( fileName ) )
return fileName; return fileName;
else 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 );
}
}
} }
......
...@@ -60,10 +60,8 @@ bool WinEDA_App::ReCreatePrjConfig( const wxString& fileName, ...@@ -60,10 +60,8 @@ bool WinEDA_App::ReCreatePrjConfig( const wxString& fileName,
/* Update the library search path list if a new project file is loaded. */ /* Update the library search path list if a new project file is loaded. */
if( m_projectFileName != fn ) if( m_projectFileName != fn )
{ {
if( m_libSearchPaths.Index( fn.GetPath() ) != wxNOT_FOUND ) RemoveLibraryPath( m_projectFileName.GetPath() );
m_libSearchPaths.Remove( fn.GetPath() ); InsertLibraryPath( fn.GetPath(), 0 );
m_libSearchPaths.Insert( fn.GetPath(), 0 );
m_projectFileName = fn; m_projectFileName = fn;
} }
......
...@@ -39,12 +39,7 @@ void Read_Config( const wxString& FileName ) ...@@ -39,12 +39,7 @@ void Read_Config( const wxString& FileName )
if( fn.GetExt() != ProjectFileExtension ) if( fn.GetExt() != ProjectFileExtension )
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
if( wxGetApp().GetLibraryPathList().Index( g_UserLibDirBuffer ) != wxNOT_FOUND ) wxGetApp().RemoveLibraryPath( g_UserLibDirBuffer );
{
wxLogDebug( wxT( "Removing path <%s> to library path search list." ),
g_UserLibDirBuffer.c_str() );
wxGetApp().GetLibraryPathList().Remove( g_UserLibDirBuffer );
}
wxGetApp().ReadProjectConfig( fn.GetFullPath(), wxGetApp().ReadProjectConfig( fn.GetFullPath(),
GROUP, ParamCfgList, FALSE ); GROUP, ParamCfgList, FALSE );
...@@ -52,13 +47,8 @@ void Read_Config( const wxString& FileName ) ...@@ -52,13 +47,8 @@ void Read_Config( const wxString& FileName )
if( g_NetlistFileExtension.IsEmpty() ) if( g_NetlistFileExtension.IsEmpty() )
g_NetlistFileExtension = wxT( "net" ); g_NetlistFileExtension = wxT( "net" );
if( wxFileName::DirExists( g_UserLibDirBuffer ) /* User library path takes precedent over default library search paths. */
&& wxGetApp().GetLibraryPathList().Index( g_UserLibDirBuffer ) == wxNOT_FOUND ) wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 );
{
wxLogDebug( wxT( "Adding path <%s> to library path search list." ),
g_UserLibDirBuffer.c_str() );
wxGetApp().GetLibraryPathList().Add( g_UserLibDirBuffer );
}
} }
......
...@@ -159,12 +159,7 @@ bool Read_Config( const wxString& CfgFileName, bool ForceRereadConfig ) ...@@ -159,12 +159,7 @@ bool Read_Config( const wxString& CfgFileName, bool ForceRereadConfig )
* extension (.pro). */ * extension (.pro). */
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
if( wxGetApp().GetLibraryPathList().Index( g_UserLibDirBuffer ) != wxNOT_FOUND ) wxGetApp().RemoveLibraryPath( g_UserLibDirBuffer );
{
wxLogDebug( wxT( "Removing path <%s> to library path search list." ),
g_UserLibDirBuffer.c_str() );
wxGetApp().GetLibraryPathList().Remove( g_UserLibDirBuffer );
}
if( !wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, ParamCfgList, if( !wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, ParamCfgList,
ForceRereadConfig ? FALSE : TRUE ) ) ForceRereadConfig ? FALSE : TRUE ) )
...@@ -173,13 +168,8 @@ bool Read_Config( const wxString& CfgFileName, bool ForceRereadConfig ) ...@@ -173,13 +168,8 @@ bool Read_Config( const wxString& CfgFileName, bool ForceRereadConfig )
IsRead = FALSE; IsRead = FALSE;
} }
if( wxFileName::DirExists( g_UserLibDirBuffer ) /* User library path takes precedent over default library search paths. */
&& wxGetApp().GetLibraryPathList().Index( g_UserLibDirBuffer ) == wxNOT_FOUND ) wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 );
{
wxLogDebug( wxT( "Adding path <%s> to library path search list." ),
g_UserLibDirBuffer.c_str() );
wxGetApp().GetLibraryPathList().Add( g_UserLibDirBuffer );
}
// If the list is void, load the libraries "power.lib" and "device.lib" // If the list is void, load the libraries "power.lib" and "device.lib"
if( g_LibName_List.GetCount() == 0 ) if( g_LibName_List.GetCount() == 0 )
......
...@@ -153,11 +153,11 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, ...@@ -153,11 +153,11 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
// Loading the project library cache // Loading the project library cache
wxFileName fn = g_RootSheet->m_AssociatedScreen->m_FileName; wxFileName fn = g_RootSheet->m_AssociatedScreen->m_FileName;
fn.SetExt( wxT( "cache.lib" ) ); fn.SetExt( wxT( "cache.lib" ) );
wxLogDebug( wxT( "Load schematic cache library file <%s>" ),
fn.GetFullPath().c_str() );
if( fn.FileExists() ) if( fn.FileExists() )
{ {
wxLogDebug( wxT( "Load schematic cache library file <%s>" ),
fn.GetFullPath().c_str() );
msg = wxT( "Load " ) + fn.GetFullPath(); msg = wxT( "Load " ) + fn.GetFullPath();
LibraryStruct* LibCache = LoadLibraryName( this, fn.GetFullPath(), LibraryStruct* LibCache = LoadLibraryName( this, fn.GetFullPath(),
fn.GetName() ); fn.GetName() );
......
...@@ -137,6 +137,8 @@ public: ...@@ -137,6 +137,8 @@ public:
{ {
return FindLibraryPath( fileName.GetFullPath() ); return FindLibraryPath( fileName.GetFullPath() );
} }
void RemoveLibraryPath( const wxString& path );
void InsertLibraryPath( const wxString& path, size_t index );
}; };
/* /*
......
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
void ReDraw( wxDC* DC, bool erasebg = TRUE ); void ReDraw( wxDC* DC, bool erasebg = TRUE );
void PrintPage( wxDC* DC, bool Print_Sheet_Ref, int PrintMask, bool aPrintMirrorMode ); void PrintPage( wxDC* DC, bool Print_Sheet_Ref, int PrintMask, bool aPrintMirrorMode );
void DrawBackGround( wxDC* DC ); void DrawBackGround( wxDC* DC );
void m_Draw_Auxiliary_Axis( wxDC* DC, int drawmode ); void DrawAuxiliaryAxis( wxDC* DC, int drawmode );
void OnEraseBackground( wxEraseEvent& event ); void OnEraseBackground( wxEraseEvent& event );
void OnActivate( wxActivateEvent& event ); void OnActivate( wxActivateEvent& event );
......
...@@ -317,9 +317,9 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -317,9 +317,9 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break; break;
case ID_PCB_PLACE_OFFSET_COORD_BUTT: case ID_PCB_PLACE_OFFSET_COORD_BUTT:
DrawPanel->m_Draw_Auxiliary_Axis( DC, GR_XOR ); DrawPanel->DrawAuxiliaryAxis( DC, GR_XOR );
m_Auxiliary_Axis_Position = GetScreen()->m_Curseur; m_Auxiliary_Axis_Position = GetScreen()->m_Curseur;
DrawPanel->m_Draw_Auxiliary_Axis( DC, GR_COPY ); DrawPanel->DrawAuxiliaryAxis( DC, GR_COPY );
GetScreen()->SetModify(); GetScreen()->SetModify();
break; break;
......
...@@ -171,12 +171,7 @@ bool Read_Config( const wxString& projectFileName ) ...@@ -171,12 +171,7 @@ bool Read_Config( const wxString& projectFileName )
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
} }
if( wxGetApp().GetLibraryPathList().Index( g_UserLibDirBuffer ) != wxNOT_FOUND ) wxGetApp().RemoveLibraryPath( g_UserLibDirBuffer );
{
wxLogDebug( wxT( "Removing path <%s> to library path search list." ),
g_UserLibDirBuffer.c_str() );
wxGetApp().GetLibraryPathList().Remove( g_UserLibDirBuffer );
}
/* Init des valeurs par defaut */ /* Init des valeurs par defaut */
g_LibName_List.Clear(); g_LibName_List.Clear();
...@@ -184,16 +179,10 @@ bool Read_Config( const wxString& projectFileName ) ...@@ -184,16 +179,10 @@ bool Read_Config( const wxString& projectFileName )
wxGetApp().ReadProjectConfig( fn.GetFullPath(), wxGetApp().ReadProjectConfig( fn.GetFullPath(),
GROUP, ParamCfgList, FALSE ); GROUP, ParamCfgList, FALSE );
/* Traitement des variables particulieres: */ /* User library path takes precedent over default library search paths. */
wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 );
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 );
}
/* Traitement des variables particulieres: */
g_DesignSettings.m_TrackWidthHistory[0] = g_DesignSettings.m_CurrentTrackWidth; g_DesignSettings.m_TrackWidthHistory[0] = g_DesignSettings.m_CurrentTrackWidth;
g_DesignSettings.m_ViaSizeHistory[0] = g_DesignSettings.m_CurrentViaSize; g_DesignSettings.m_ViaSizeHistory[0] = g_DesignSettings.m_CurrentViaSize;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment