Commit e07590f9 authored by jean-pierre charras's avatar jean-pierre charras

All: fix a minor issue in drawtext.cpp

Pcbnew: load footprint from modview: Because modview allows user to choose the footprint library, the selected library is forced when the footprint is loaded.
I am not sure this is 100% better, but this new behavior has some advantages, mainly in the footprint editor (you can load a footprint outside the selected library)
parent e5740af0
...@@ -389,7 +389,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, ...@@ -389,7 +389,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
/* if a text size is too small, the text cannot be drawn, and it is drawn as a single /* if a text size is too small, the text cannot be drawn, and it is drawn as a single
* graphic line */ * graphic line */
if( aDC && ( aDC->LogicalToDeviceYRel( std::abs( aSize.y ) ) < MIN_TEXT_SIZE )) if( aDC && ( aDC->LogicalToDeviceYRel( std::abs( aSize.y ) ) < MIN_DRAWABLE_TEXT_SIZE ))
{ {
// draw the text as a line always vertically centered // draw the text as a line always vertically centered
wxPoint end( current_char_pos.x + dx, current_char_pos.y ); wxPoint end( current_char_pos.x + dx, current_char_pos.y );
......
...@@ -10,9 +10,20 @@ ...@@ -10,9 +10,20 @@
#include <base_struct.h> #include <base_struct.h>
#include <eda_text.h> // EDA_TEXT_HJUSTIFY_T and EDA_TEXT_VJUSTIFY_T #include <eda_text.h> // EDA_TEXT_HJUSTIFY_T and EDA_TEXT_VJUSTIFY_T
/// Minimum dimension in pixel for drawing text /* Minimum dimension in pixel for drawing/no drawing a text
* used in Pcbnew to decide to draw (or not) some texts
* ( like net names on pads/tracks )
* When a text height is smaller than MIN_TEXT_SIZE,
* it is not drawn by Pcbnew
*/
#define MIN_TEXT_SIZE 5 #define MIN_TEXT_SIZE 5
/* Absolute minimum dimension in pixel to draw a text as text or a line
* When a text height is smaller than MIN_DRAWABLE_TEXT_SIZE,
* it is drawn, but like a line by the draw text function
*/
#define MIN_DRAWABLE_TEXT_SIZE 3
class EDA_DRAW_PANEL; class EDA_DRAW_PANEL;
class PLOTTER; class PLOTTER;
......
...@@ -132,7 +132,12 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void ) ...@@ -132,7 +132,12 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
wxMilliSleep( 50 ); wxMilliSleep( 50 );
} }
wxString fpname = viewer->GetSelectedFootprint(); // Returnd the full fp name, i.e. the lib name and th fp name,
// separated by a '/'
// (/ is now an illegal char in fp names)
wxString fpname = viewer->GetSelectedLibraryFullName();
fpname << wxT("/") << viewer->GetSelectedFootprint();
viewer->Destroy(); viewer->Destroy();
return fpname; return fpname;
...@@ -146,6 +151,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -146,6 +151,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
MODULE* module; MODULE* module;
wxPoint curspos = GetScreen()->GetCrossHairPosition(); wxPoint curspos = GetScreen()->GetCrossHairPosition();
wxString moduleName, keys; wxString moduleName, keys;
wxString libName = aLibrary;
bool allowWildSeach = true; bool allowWildSeach = true;
static wxArrayString HistoryList; static wxArrayString HistoryList;
...@@ -162,7 +168,12 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -162,7 +168,12 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
if( dlg.m_GetExtraFunction ) if( dlg.m_GetExtraFunction )
{ {
moduleName = SelectFootprintFromLibBrowser(); // SelectFootprintFromLibBrowser() returns the
// "full" footprint name, i.e.
// <lib_name>/<footprint name>
wxString full_fpname = SelectFootprintFromLibBrowser();
moduleName = full_fpname.AfterLast( '/' );
libName = full_fpname.BeforeLast( '/' );
} }
else else
{ {
...@@ -179,7 +190,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -179,7 +190,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
{ {
allowWildSeach = false; allowWildSeach = false;
keys = moduleName; keys = moduleName;
moduleName = Select_1_Module_From_List( this, aLibrary, wxEmptyString, keys ); moduleName = Select_1_Module_From_List( this, libName, wxEmptyString, keys );
if( moduleName.IsEmpty() ) // Cancel command if( moduleName.IsEmpty() ) // Cancel command
{ {
...@@ -191,7 +202,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -191,7 +202,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
|| ( moduleName.Contains( wxT( "*" ) ) ) ) // Selection wild card || ( moduleName.Contains( wxT( "*" ) ) ) ) // Selection wild card
{ {
allowWildSeach = false; allowWildSeach = false;
moduleName = Select_1_Module_From_List( this, aLibrary, moduleName, wxEmptyString ); moduleName = Select_1_Module_From_List( this, libName, moduleName, wxEmptyString );
if( moduleName.IsEmpty() ) if( moduleName.IsEmpty() )
{ {
...@@ -200,7 +211,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -200,7 +211,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
} }
} }
module = GetModuleLibrary( aLibrary, moduleName, false ); module = GetModuleLibrary( libName, moduleName, false );
if( !module && allowWildSeach ) // Search with wild card if( !module && allowWildSeach ) // Search with wild card
{ {
...@@ -209,7 +220,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -209,7 +220,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' ); wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' );
moduleName = wildname; moduleName = wildname;
moduleName = Select_1_Module_From_List( this, aLibrary, moduleName, wxEmptyString ); moduleName = Select_1_Module_From_List( this, libName, moduleName, wxEmptyString );
if( moduleName.IsEmpty() ) if( moduleName.IsEmpty() )
{ {
...@@ -218,7 +229,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary, ...@@ -218,7 +229,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
} }
else else
{ {
module = GetModuleLibrary( aLibrary, moduleName, true ); module = GetModuleLibrary( libName, moduleName, true );
} }
} }
......
...@@ -145,6 +145,13 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event ) ...@@ -145,6 +145,13 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
} }
const wxString FOOTPRINT_VIEWER_FRAME::GetSelectedLibraryFullName( void )
{
wxString fullname = m_libraryName + wxT(".") + LegacyFootprintLibPathExtension;
return fullname;
}
/* Routine to view one selected library content. */ /* Routine to view one selected library content. */
void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode ) void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
{ {
...@@ -171,8 +178,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode ) ...@@ -171,8 +178,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
SetCurItem( NULL ); SetCurItem( NULL );
// Delete the current footprint // Delete the current footprint
GetBoard()->m_Modules.DeleteAll(); GetBoard()->m_Modules.DeleteAll();
GetModuleLibrary( m_libraryName + wxT(".") + LegacyFootprintLibPathExtension, GetModuleLibrary( GetSelectedLibraryFullName(), m_footprintName, true );
m_footprintName, true );
Update3D_Frame(); Update3D_Frame();
} }
......
...@@ -84,6 +84,7 @@ public: ...@@ -84,6 +84,7 @@ public:
static FOOTPRINT_VIEWER_FRAME* GetActiveFootprintViewer(); static FOOTPRINT_VIEWER_FRAME* GetActiveFootprintViewer();
wxString& GetSelectedFootprint( void ) const { return m_selectedFootprintName; } wxString& GetSelectedFootprint( void ) const { return m_selectedFootprintName; }
const wxString GetSelectedLibraryFullName( void );
private: private:
......
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