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,
/* if a text size is too small, the text cannot be drawn, and it is drawn as a single
* 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
wxPoint end( current_char_pos.x + dx, current_char_pos.y );
......@@ -583,12 +583,12 @@ void DrawGraphicHaloText( EDA_DRAW_PANEL * aPanel,
aColor2 = c;
}
DrawGraphicText( aPanel, aDC, aPos, aColor1, aText, aOrient, aSize,
aH_justify, aV_justify, aWidth, aItalic, aBold,
DrawGraphicText( aPanel, aDC, aPos, aColor1, aText, aOrient, aSize,
aH_justify, aV_justify, aWidth, aItalic, aBold,
aCallback, aPlotter );
DrawGraphicText( aPanel, aDC, aPos, aColor2, aText, aOrient, aSize,
aH_justify, aV_justify, aWidth / 4, aItalic, aBold,
DrawGraphicText( aPanel, aDC, aPos, aColor2, aText, aOrient, aSize,
aH_justify, aV_justify, aWidth / 4, aItalic, aBold,
aCallback, aPlotter );
}
......
......@@ -10,9 +10,20 @@
#include <base_struct.h>
#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
/* 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 PLOTTER;
......
......@@ -132,7 +132,12 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
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();
return fpname;
......@@ -146,6 +151,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
MODULE* module;
wxPoint curspos = GetScreen()->GetCrossHairPosition();
wxString moduleName, keys;
wxString libName = aLibrary;
bool allowWildSeach = true;
static wxArrayString HistoryList;
......@@ -162,7 +168,12 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
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
{
......@@ -179,7 +190,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
{
allowWildSeach = false;
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
{
......@@ -191,7 +202,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
|| ( moduleName.Contains( wxT( "*" ) ) ) ) // Selection wild card
{
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() )
{
......@@ -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
{
......@@ -209,7 +220,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' );
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() )
{
......@@ -218,7 +229,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
}
else
{
module = GetModuleLibrary( aLibrary, moduleName, true );
module = GetModuleLibrary( libName, moduleName, true );
}
}
......
......@@ -87,7 +87,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentLibrary( wxCommandEvent& event )
wxArrayString headers;
headers.Add( wxT("Library") );
std::vector<wxArrayString> itemsToDisplay;
// Conversion from wxArrayString to vector of ArrayString
for( unsigned i = 0; i < g_LibraryNames.GetCount(); i++ )
{
......@@ -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. */
void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
{
......@@ -171,8 +178,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
SetCurItem( NULL );
// Delete the current footprint
GetBoard()->m_Modules.DeleteAll();
GetModuleLibrary( m_libraryName + wxT(".") + LegacyFootprintLibPathExtension,
m_footprintName, true );
GetModuleLibrary( GetSelectedLibraryFullName(), m_footprintName, true );
Update3D_Frame();
}
......
......@@ -58,10 +58,10 @@ private:
wxString m_configPath; // subpath for configuration
protected:
static wxString m_libraryName; // Current selected libary
static wxString m_footprintName; // Current selected footprint
static wxString m_selectedFootprintName; // When the viewer is used to select a footprint
// the selected footprint is here
static wxString m_libraryName; // Current selected libary
static wxString m_footprintName; // Current selected footprint
static wxString m_selectedFootprintName; // When the viewer is used to select a footprint
// the selected footprint is here
public:
FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* parent, wxSemaphore* semaphore = NULL,
......@@ -84,6 +84,7 @@ public:
static FOOTPRINT_VIEWER_FRAME* GetActiveFootprintViewer();
wxString& GetSelectedFootprint( void ) const { return m_selectedFootprintName; }
const wxString GetSelectedLibraryFullName( void );
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