More work on fp lib table wizard: add a button to import the full list of .pretty libs on github.
* if the current select plugin is the github plugin, one can select some of these libraries and add them to the table * if the current select plugin is the kicad plugin, one can select some of these libraries and download them to make alocal copy. They can added to the table after they are downloaded.
This commit is contained in:
parent
b269128b8c
commit
0b1a6fd7c3
|
@ -212,29 +212,26 @@ void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit )
|
|||
}
|
||||
|
||||
|
||||
wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter )
|
||||
void wxStringSplit( const wxString& aText, wxArrayString& aStrings, wxChar aSplitter )
|
||||
{
|
||||
wxArrayString* list = new wxArrayString();
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
int index = aString.Find( aSplitter );
|
||||
|
||||
if( index == wxNOT_FOUND )
|
||||
break;
|
||||
|
||||
wxString tmp;
|
||||
tmp = aString.Mid( 0, index );
|
||||
aString = aString.Mid( index + 1, aString.size() - index );
|
||||
list->Add( tmp );
|
||||
}
|
||||
|
||||
if( !aString.IsEmpty() )
|
||||
for( unsigned ii = 0; ii < aText.Length(); ii++ )
|
||||
{
|
||||
list->Add( aString );
|
||||
if( aText[ii] == aSplitter )
|
||||
{
|
||||
aStrings.Add( tmp );
|
||||
tmp.Clear();
|
||||
}
|
||||
|
||||
return list;
|
||||
else
|
||||
tmp << aText[ii];
|
||||
}
|
||||
|
||||
if( !tmp.IsEmpty() )
|
||||
{
|
||||
aStrings.Add( tmp );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -636,6 +636,7 @@ void PLOTTER::Text( const wxPoint& aPos,
|
|||
{
|
||||
// EDA_TEXT needs for calculations of the position of every
|
||||
// line according to orientation and justifications
|
||||
wxArrayString strings;
|
||||
EDA_TEXT* multilineText = new EDA_TEXT( aText );
|
||||
multilineText->SetSize( aSize );
|
||||
multilineText->SetTextPosition( aPos );
|
||||
|
@ -646,15 +647,15 @@ void PLOTTER::Text( const wxPoint& aPos,
|
|||
multilineText->SetMultilineAllowed( aMultilineAllowed );
|
||||
|
||||
std::vector<wxPoint> positions;
|
||||
wxArrayString* list = wxStringSplit( aText, '\n' );
|
||||
positions.reserve( list->Count() );
|
||||
wxStringSplit( aText, strings, '\n' );
|
||||
positions.reserve( strings.Count() );
|
||||
|
||||
multilineText->GetPositionsOfLinesOfMultilineText(
|
||||
positions, list->Count() );
|
||||
positions, strings.Count() );
|
||||
|
||||
for( unsigned ii = 0; ii < list->Count(); ii++ )
|
||||
for( unsigned ii = 0; ii < strings.Count(); ii++ )
|
||||
{
|
||||
wxString& txt = list->Item( ii );
|
||||
wxString& txt = strings.Item( ii );
|
||||
DrawGraphicText( NULL, NULL, positions[ii], aColor, txt,
|
||||
aOrient, aSize,
|
||||
aH_justify, aV_justify,
|
||||
|
@ -663,8 +664,8 @@ void PLOTTER::Text( const wxPoint& aPos,
|
|||
NULL,
|
||||
this );
|
||||
}
|
||||
|
||||
delete multilineText;
|
||||
delete list;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -120,23 +120,23 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
|
|||
{
|
||||
EDA_RECT rect;
|
||||
wxPoint pos;
|
||||
wxArrayString* list = NULL;
|
||||
wxArrayString strings;
|
||||
wxString text = GetShownText();
|
||||
int thickness = ( aThickness < 0 ) ? m_Thickness : aThickness;
|
||||
int linecount = 1;
|
||||
|
||||
if( m_MultilineAllowed )
|
||||
{
|
||||
list = wxStringSplit( text, '\n' );
|
||||
wxStringSplit( text, strings, '\n' );
|
||||
|
||||
if ( list->GetCount() ) // GetCount() == 0 for void strings
|
||||
if ( strings.GetCount() ) // GetCount() == 0 for void strings
|
||||
{
|
||||
if( aLine >= 0 && (aLine < (int)list->GetCount()) )
|
||||
text = list->Item( aLine );
|
||||
if( aLine >= 0 && (aLine < (int)strings.GetCount()) )
|
||||
text = strings.Item( aLine );
|
||||
else
|
||||
text = list->Item( 0 );
|
||||
text = strings.Item( 0 );
|
||||
|
||||
linecount = list->GetCount();
|
||||
linecount = strings.GetCount();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,19 +157,17 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
|
|||
rect.Move( wxPoint( 0, -extra_dy / 2 ) ); // move origin by the half extra interval
|
||||
|
||||
// for multiline texts and aLine < 0, merge all rectangles
|
||||
if( m_MultilineAllowed && list && aLine < 0 )
|
||||
if( m_MultilineAllowed && aLine < 0 )
|
||||
{
|
||||
for( unsigned ii = 1; ii < list->GetCount(); ii++ )
|
||||
for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
|
||||
{
|
||||
text = list->Item( ii );
|
||||
text = strings.Item( ii );
|
||||
dx = LenSize( text );
|
||||
textsize.x = std::max( textsize.x, dx );
|
||||
textsize.y += dy;
|
||||
}
|
||||
}
|
||||
|
||||
delete list;
|
||||
|
||||
rect.SetSize( textsize );
|
||||
|
||||
/* Now, calculate the rect origin, according to text justification
|
||||
|
@ -272,19 +270,18 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
|
|||
if( m_MultilineAllowed )
|
||||
{
|
||||
std::vector<wxPoint> positions;
|
||||
wxArrayString* list = wxStringSplit( GetShownText(), '\n' );
|
||||
positions.reserve( list->Count() );
|
||||
wxArrayString strings;
|
||||
wxStringSplit( GetShownText(), strings, '\n' );
|
||||
positions.reserve( strings.Count() );
|
||||
|
||||
GetPositionsOfLinesOfMultilineText(positions, list->Count() );
|
||||
GetPositionsOfLinesOfMultilineText(positions, strings.Count() );
|
||||
|
||||
for( unsigned ii = 0; ii < list->Count(); ii++ )
|
||||
for( unsigned ii = 0; ii < strings.Count(); ii++ )
|
||||
{
|
||||
wxString& txt = list->Item( ii );
|
||||
wxString& txt = strings.Item( ii );
|
||||
drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
|
||||
aDrawMode, aFillMode, txt, positions[ii] );
|
||||
}
|
||||
|
||||
delete (list);
|
||||
}
|
||||
else
|
||||
drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
|
||||
|
@ -489,22 +486,21 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuf
|
|||
|
||||
if( IsMultilineAllowed() )
|
||||
{
|
||||
wxArrayString* list = wxStringSplit( GetShownText(), '\n' );
|
||||
wxArrayString strings_list;
|
||||
wxStringSplit( GetShownText(), strings_list, wxChar('\n') );
|
||||
std::vector<wxPoint> positions;
|
||||
positions.reserve( list->Count() );
|
||||
GetPositionsOfLinesOfMultilineText( positions, list->Count() );
|
||||
positions.reserve( strings_list.Count() );
|
||||
GetPositionsOfLinesOfMultilineText( positions,strings_list.Count() );
|
||||
|
||||
for( unsigned ii = 0; ii < list->Count(); ii++ )
|
||||
for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
|
||||
{
|
||||
wxString txt = list->Item( ii );
|
||||
wxString txt = strings_list.Item( ii );
|
||||
DrawGraphicText( NULL, NULL, positions[ii], color,
|
||||
txt, GetOrientation(), size,
|
||||
GetHorizJustify(), GetVertJustify(),
|
||||
GetThickness(), IsItalic(),
|
||||
true, addTextSegmToBuffer );
|
||||
}
|
||||
|
||||
delete list;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -51,23 +51,20 @@ void HTML_MESSAGE_BOX::ListClear()
|
|||
|
||||
void HTML_MESSAGE_BOX::ListSet( const wxString& aList )
|
||||
{
|
||||
// wxArrayString* wxStringSplit( wxString txt, wxChar splitter );
|
||||
|
||||
wxArrayString* strings_list = wxStringSplit( aList, wxChar( '\n' ) );
|
||||
wxArrayString strings_list;
|
||||
wxStringSplit( aList, strings_list, wxChar( '\n' ) );
|
||||
|
||||
wxString msg = wxT( "<ul>" );
|
||||
|
||||
for ( unsigned ii = 0; ii < strings_list->GetCount(); ii++ )
|
||||
for ( unsigned ii = 0; ii < strings_list.GetCount(); ii++ )
|
||||
{
|
||||
msg += wxT( "<li>" );
|
||||
msg += strings_list->Item( ii ) + wxT( "</li>" );
|
||||
msg += strings_list.Item( ii ) + wxT( "</li>" );
|
||||
}
|
||||
|
||||
msg += wxT( "</ul>" );
|
||||
|
||||
m_htmlWindow->AppendToPage( msg );
|
||||
|
||||
delete strings_list;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -90,6 +90,31 @@ void DIALOG_CONFIG_EQUFILES::Init()
|
|||
|
||||
}
|
||||
|
||||
void DIALOG_CONFIG_EQUFILES::OnEditEquFile( wxCommandEvent& event )
|
||||
{
|
||||
wxString editorname = Pgm().GetEditorName();
|
||||
|
||||
if( editorname.IsEmpty() )
|
||||
{
|
||||
wxMessageBox( _( "No editor defined in Kicad. Please chose it" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
wxArrayInt selections;
|
||||
m_ListEquiv->GetSelections( selections );
|
||||
|
||||
wxString fullFileNames, tmp;
|
||||
|
||||
for( unsigned ii = 0; ii < selections.GetCount(); ii++ )
|
||||
{
|
||||
tmp = m_ListEquiv->GetString( selections[ii] );
|
||||
fullFileNames << wxT( " \"" ) << wxExpandEnvVars( tmp ) << wxT( "\"" );
|
||||
m_ListChanged = true;
|
||||
}
|
||||
|
||||
ExecuteFile( this, editorname, fullFileNames );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_CONFIG_EQUFILES::OnCancelClick( wxCommandEvent& event )
|
||||
{
|
||||
|
@ -126,10 +151,9 @@ void DIALOG_CONFIG_EQUFILES::OnCloseWindow( wxCloseEvent& event )
|
|||
void DIALOG_CONFIG_EQUFILES::OnButtonMoveUp( wxCommandEvent& event )
|
||||
/********************************************************************/
|
||||
{
|
||||
wxListBox * list = m_ListEquiv;
|
||||
wxArrayInt selections;
|
||||
|
||||
list->GetSelections( selections );
|
||||
m_ListEquiv->GetSelections( selections );
|
||||
|
||||
if ( selections.GetCount() <= 0 ) // No selection.
|
||||
return;
|
||||
|
@ -137,7 +161,7 @@ void DIALOG_CONFIG_EQUFILES::OnButtonMoveUp( wxCommandEvent& event )
|
|||
if( selections[0] == 0 ) // The first lib is selected. cannot move up it
|
||||
return;
|
||||
|
||||
wxArrayString libnames = list->GetStrings();
|
||||
wxArrayString libnames = m_ListEquiv->GetStrings();
|
||||
|
||||
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
|
||||
{
|
||||
|
@ -145,13 +169,13 @@ void DIALOG_CONFIG_EQUFILES::OnButtonMoveUp( wxCommandEvent& event )
|
|||
EXCHG( libnames[jj], libnames[jj-1] );
|
||||
}
|
||||
|
||||
list->Set( libnames );
|
||||
m_ListEquiv->Set( libnames );
|
||||
|
||||
// Reselect previously selected names
|
||||
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
|
||||
{
|
||||
int jj = selections[ii];
|
||||
list->SetSelection( jj-1 );
|
||||
m_ListEquiv->SetSelection( jj-1 );
|
||||
}
|
||||
|
||||
m_ListChanged = true;
|
||||
|
|
|
@ -48,6 +48,7 @@ private:
|
|||
void OnOkClick( wxCommandEvent& event );
|
||||
void OnCancelClick( wxCommandEvent& event );
|
||||
void OnAddFiles( wxCommandEvent& event );
|
||||
void OnEditEquFile( wxCommandEvent& event );
|
||||
void OnRemoveFiles( wxCommandEvent& event );
|
||||
void OnButtonMoveUp( wxCommandEvent& event );
|
||||
void OnButtonMoveDown( wxCommandEvent& event );
|
||||
|
|
|
@ -47,6 +47,9 @@ DIALOG_CONFIG_EQUFILES_BASE::DIALOG_CONFIG_EQUFILES_BASE( wxWindow* parent, wxWi
|
|||
m_buttonMoveDown = new wxButton( this, ID_EQU_DOWN, _("Move Down"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizerButtons->Add( m_buttonMoveDown, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_buttonEdit = new wxButton( this, wxID_ANY, _("Edit Equ File"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizerButtons->Add( m_buttonEdit, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
sbEquivChoiceSizer->Add( bSizerButtons, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
|
@ -75,7 +78,9 @@ DIALOG_CONFIG_EQUFILES_BASE::DIALOG_CONFIG_EQUFILES_BASE( wxWindow* parent, wxWi
|
|||
// Columns
|
||||
m_gridEnvVars->EnableDragColMove( false );
|
||||
m_gridEnvVars->EnableDragColSize( true );
|
||||
m_gridEnvVars->SetColLabelSize( 30 );
|
||||
m_gridEnvVars->SetColLabelSize( 25 );
|
||||
m_gridEnvVars->SetColLabelValue( 0, _("Name") );
|
||||
m_gridEnvVars->SetColLabelValue( 1, _("Value") );
|
||||
m_gridEnvVars->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
|
||||
|
||||
// Rows
|
||||
|
@ -126,6 +131,7 @@ DIALOG_CONFIG_EQUFILES_BASE::DIALOG_CONFIG_EQUFILES_BASE( wxWindow* parent, wxWi
|
|||
m_buttonRemoveEqu->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnRemoveFiles ), NULL, this );
|
||||
m_buttonMoveUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnButtonMoveUp ), NULL, this );
|
||||
m_buttonMoveDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnButtonMoveDown ), NULL, this );
|
||||
m_buttonEdit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnEditEquFile ), NULL, this );
|
||||
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnCancelClick ), NULL, this );
|
||||
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnOkClick ), NULL, this );
|
||||
}
|
||||
|
@ -138,6 +144,7 @@ DIALOG_CONFIG_EQUFILES_BASE::~DIALOG_CONFIG_EQUFILES_BASE()
|
|||
m_buttonRemoveEqu->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnRemoveFiles ), NULL, this );
|
||||
m_buttonMoveUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnButtonMoveUp ), NULL, this );
|
||||
m_buttonMoveDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnButtonMoveDown ), NULL, this );
|
||||
m_buttonEdit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnEditEquFile ), NULL, this );
|
||||
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnCancelClick ), NULL, this );
|
||||
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnOkClick ), NULL, this );
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
<property name="minimum_size"></property>
|
||||
<property name="name">DIALOG_CONFIG_EQUFILES_BASE</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size">454,284</property>
|
||||
<property name="size">454,338</property>
|
||||
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
||||
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
||||
<property name="title"></property>
|
||||
|
@ -565,6 +565,94 @@
|
|||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxButton" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default">0</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Edit Equ File</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_buttonEdit</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnButtonClick">OnEditEquFile</event>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
<event name="OnLeaveWindow"></event>
|
||||
<event name="OnLeftDClick"></event>
|
||||
<event name="OnLeftDown"></event>
|
||||
<event name="OnLeftUp"></event>
|
||||
<event name="OnMiddleDClick"></event>
|
||||
<event name="OnMiddleDown"></event>
|
||||
<event name="OnMiddleUp"></event>
|
||||
<event name="OnMotion"></event>
|
||||
<event name="OnMouseEvents"></event>
|
||||
<event name="OnMouseWheel"></event>
|
||||
<event name="OnPaint"></event>
|
||||
<event name="OnRightDClick"></event>
|
||||
<event name="OnRightDown"></event>
|
||||
<event name="OnRightUp"></event>
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
|
@ -697,8 +785,8 @@
|
|||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="col_label_horiz_alignment">wxALIGN_CENTRE</property>
|
||||
<property name="col_label_size">30</property>
|
||||
<property name="col_label_values"></property>
|
||||
<property name="col_label_size">25</property>
|
||||
<property name="col_label_values">"Name" "Value"</property>
|
||||
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
|
||||
<property name="cols">2</property>
|
||||
<property name="column_sizes"></property>
|
||||
|
|
|
@ -52,6 +52,7 @@ class DIALOG_CONFIG_EQUFILES_BASE : public DIALOG_SHIM
|
|||
wxButton* m_buttonRemoveEqu;
|
||||
wxButton* m_buttonMoveUp;
|
||||
wxButton* m_buttonMoveDown;
|
||||
wxButton* m_buttonEdit;
|
||||
wxStaticText* m_staticText2;
|
||||
wxGrid* m_gridEnvVars;
|
||||
wxRadioBox* m_rbPathOptionChoice;
|
||||
|
@ -66,13 +67,14 @@ class DIALOG_CONFIG_EQUFILES_BASE : public DIALOG_SHIM
|
|||
virtual void OnRemoveFiles( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnButtonMoveUp( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnButtonMoveDown( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnEditEquFile( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
||||
DIALOG_CONFIG_EQUFILES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 454,284 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
DIALOG_CONFIG_EQUFILES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 454,338 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
~DIALOG_CONFIG_EQUFILES_BASE();
|
||||
|
||||
};
|
||||
|
|
|
@ -668,19 +668,18 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter )
|
|||
if( m_MultilineAllowed )
|
||||
{
|
||||
std::vector<wxPoint> positions;
|
||||
wxArrayString* list = wxStringSplit( GetShownText(), '\n' );
|
||||
positions.reserve( list->Count() );
|
||||
wxArrayString strings_list;
|
||||
wxStringSplit( GetShownText(), strings_list, '\n' );
|
||||
positions.reserve( strings_list.Count() );
|
||||
|
||||
GetPositionsOfLinesOfMultilineText(positions, list->Count() );
|
||||
GetPositionsOfLinesOfMultilineText(positions, strings_list.Count() );
|
||||
|
||||
for( unsigned ii = 0; ii < list->Count(); ii++ )
|
||||
for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
|
||||
{
|
||||
wxString& txt = list->Item( ii );
|
||||
wxString& txt = strings_list.Item( ii );
|
||||
aPlotter->Text( positions[ii], color, txt, m_Orient, m_Size, m_HJustify,
|
||||
m_VJustify, thickness, m_Italic, m_Bold );
|
||||
}
|
||||
|
||||
delete (list);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -339,11 +339,11 @@ double RoundTo0( double x, double precision );
|
|||
/**
|
||||
* Function wxStringSplit
|
||||
* splits \a aString to a string list separated at \a aSplitter.
|
||||
* @return the list
|
||||
* @param aString is the text to split
|
||||
* @param aText is the text to split
|
||||
* @param aStrings will contain the splitted lines
|
||||
* @param aSplitter is the 'split' character
|
||||
*/
|
||||
wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter );
|
||||
void wxStringSplit( const wxString& aText, wxArrayString& aStrings, wxChar aSplitter );
|
||||
|
||||
/**
|
||||
* Function GetRunningMicroSecs
|
||||
|
|
|
@ -403,22 +403,21 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(
|
|||
|
||||
if( IsMultilineAllowed() )
|
||||
{
|
||||
wxArrayString* list = wxStringSplit( GetShownText(), '\n' );
|
||||
wxArrayString strings_list;
|
||||
wxStringSplit( GetShownText(), strings_list, '\n' );
|
||||
std::vector<wxPoint> positions;
|
||||
positions.reserve( list->Count() );
|
||||
GetPositionsOfLinesOfMultilineText( positions, list->Count() );
|
||||
positions.reserve( strings_list.Count() );
|
||||
GetPositionsOfLinesOfMultilineText( positions, strings_list.Count() );
|
||||
|
||||
for( unsigned ii = 0; ii < list->Count(); ii++ )
|
||||
for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
|
||||
{
|
||||
wxString txt = list->Item( ii );
|
||||
wxString txt = strings_list.Item( ii );
|
||||
DrawGraphicText( NULL, NULL, positions[ii], color,
|
||||
txt, GetOrientation(), size,
|
||||
GetHorizJustify(), GetVertJustify(),
|
||||
GetThickness(), IsItalic(),
|
||||
true, addTextSegmToPoly );
|
||||
}
|
||||
|
||||
delete list;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -49,10 +49,13 @@
|
|||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/url.h>
|
||||
#include <wx/progdlg.h>
|
||||
|
||||
#include <pgm_base.h>
|
||||
#include <kiface_i.h>
|
||||
#include <dialog_helpers.h>
|
||||
#include <project.h> // For PROJECT_VAR_NAME definition
|
||||
#include <fp_lib_table.h> // For KISYSMOD definition
|
||||
#include <io_mgr.h>
|
||||
#include <wizard_add_fplib.h>
|
||||
#include <dialog_select_dirlist_base.h>
|
||||
|
@ -88,6 +91,9 @@ WIZARD_FPLIB_TABLE::WIZARD_FPLIB_TABLE( wxWindow* aParent, wxArrayString& aEnvVa
|
|||
m_buttonAddEV->Show( false );
|
||||
m_buttonRemoveEV->Show( false );
|
||||
|
||||
#ifndef BUILD_GITHUB_PLUGIN
|
||||
m_buttonGithubLibList->Show( false );
|
||||
#endif
|
||||
|
||||
// Gives a minimal size to the dialog, which allows displaying any page
|
||||
wxSize minsize;
|
||||
|
@ -211,7 +217,7 @@ bool WIZARD_FPLIB_TABLE::ValidateOptions()
|
|||
// Warn the user when this is the case
|
||||
wxString msg;
|
||||
|
||||
if( GetSelectedEnvVarValue().IsEmpty() )
|
||||
if( getSelectedEnvVarValue().IsEmpty() )
|
||||
{
|
||||
// PROJECT_PATH option cannot be used with empty local path
|
||||
if( m_rbPathManagement->GetSelection() == PROJECT_PATH )
|
||||
|
@ -225,7 +231,7 @@ bool WIZARD_FPLIB_TABLE::ValidateOptions()
|
|||
{
|
||||
wxMessageBox( wxString::Format(
|
||||
_("The default path defined by env var \"%s\" is empty.\nCannot use it"),
|
||||
GetChars( GetSelectedEnvVar() ) ) );
|
||||
GetChars( getSelectedEnvVar() ) ) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +240,7 @@ bool WIZARD_FPLIB_TABLE::ValidateOptions()
|
|||
if( IsGithubPlugin() )
|
||||
{
|
||||
// Github plugin cannot be used with local path; Need absolute path or valid URL
|
||||
if( !GetSelectedEnvVarValue().Lower().StartsWith( "http" ) )
|
||||
if( !getSelectedEnvVarValue().Lower().StartsWith( "http" ) )
|
||||
{
|
||||
msg = _("Github Plugin uses a valid Internet URL starting by http.\n"
|
||||
"Cannot be used as URL");
|
||||
|
@ -244,7 +250,7 @@ bool WIZARD_FPLIB_TABLE::ValidateOptions()
|
|||
}
|
||||
else
|
||||
{
|
||||
if( GetSelectedEnvVarValue().Lower().StartsWith( "http" ) )
|
||||
if( getSelectedEnvVarValue().Lower().StartsWith( "http" ) )
|
||||
{
|
||||
msg = _("This default path looks strange.\n"
|
||||
"Cannot be used for a file path");
|
||||
|
@ -267,6 +273,10 @@ void WIZARD_FPLIB_TABLE::OnPluginSelection( wxCommandEvent& event )
|
|||
|
||||
void WIZARD_FPLIB_TABLE::updateFromPlugingChoice()
|
||||
{
|
||||
#ifdef BUILD_GITHUB_PLUGIN
|
||||
m_buttonGithubLibList->Show( IsGithubPlugin() || IsKicadPlugin() );
|
||||
#endif
|
||||
|
||||
// update dialog options and widgets depending on a plugin choice
|
||||
// Project path has no sense for GITHUB_PLUGIN
|
||||
bool enablePrjPathOpt = not IsGithubPlugin();
|
||||
|
@ -293,7 +303,7 @@ void WIZARD_FPLIB_TABLE::updateFromPlugingChoice()
|
|||
{
|
||||
if( first_github_envvar < 0 )
|
||||
force_absolute_path = true;
|
||||
else if( !GetSelectedEnvVarValue().StartsWith( "http" ) )
|
||||
else if( !getSelectedEnvVarValue().StartsWith( "http" ) )
|
||||
m_gridEnvironmentVariablesList->SelectRow( first_github_envvar );
|
||||
|
||||
}
|
||||
|
@ -378,7 +388,7 @@ void WIZARD_FPLIB_TABLE::OnSelectEnvVarCell( wxGridEvent& event )
|
|||
m_gridEnvironmentVariablesList->SelectRow( event.GetRow() );
|
||||
}
|
||||
|
||||
wxString WIZARD_FPLIB_TABLE::GetSelectedEnvVar()
|
||||
wxString WIZARD_FPLIB_TABLE::getSelectedEnvVar()
|
||||
{
|
||||
wxString envVar;
|
||||
wxArrayInt selectedRows = m_gridEnvironmentVariablesList->GetSelectedRows();
|
||||
|
@ -405,7 +415,7 @@ wxString WIZARD_FPLIB_TABLE::GetSelectedEnvVar()
|
|||
}
|
||||
|
||||
|
||||
wxString WIZARD_FPLIB_TABLE::GetSelectedEnvVarValue()
|
||||
wxString WIZARD_FPLIB_TABLE::getSelectedEnvVarValue()
|
||||
{
|
||||
wxString envVarValue;
|
||||
wxArrayInt selectedRows = m_gridEnvironmentVariablesList->GetSelectedRows();
|
||||
|
@ -454,7 +464,7 @@ void WIZARD_FPLIB_TABLE::OnPageChanging( wxWizardEvent& event )
|
|||
if( ( m_rbPathManagement->GetSelection() != ABSOLUTE_PATH ) &&
|
||||
( IsGithubPlugin() ) )
|
||||
{
|
||||
wxURI uri( GetSelectedEnvVarValue() );
|
||||
wxURI uri( getSelectedEnvVarValue() );
|
||||
|
||||
// We cannot use wxURL to test the validity of the url, because
|
||||
// wxURL does not know https protocol we are using, and aways returns
|
||||
|
@ -465,7 +475,7 @@ void WIZARD_FPLIB_TABLE::OnPageChanging( wxWizardEvent& event )
|
|||
{
|
||||
wxMessageBox( wxString::Format(
|
||||
_("The URL defined by env var \"%s\" is an incorrect URL.\nCannot use it"),
|
||||
GetChars( GetSelectedEnvVar() ) ) );
|
||||
GetChars( getSelectedEnvVar() ) ) );
|
||||
event.Veto();
|
||||
}
|
||||
}
|
||||
|
@ -484,10 +494,12 @@ bool WIZARD_FPLIB_TABLE::setSecondPage()
|
|||
{
|
||||
case 0: // Kicad lib type
|
||||
m_currLibDescr = new LIB_DESCR_KICAD;
|
||||
m_buttonGithubLibList->SetLabel( _("Download Github Libs") );
|
||||
break;
|
||||
|
||||
case 1: // Github lib type
|
||||
m_currLibDescr = new LIB_DESCR_GITHUB;
|
||||
m_buttonGithubLibList->SetLabel( _("Github Libs List") );
|
||||
break;
|
||||
|
||||
case 2: // Legacy lib type
|
||||
|
@ -503,6 +515,17 @@ bool WIZARD_FPLIB_TABLE::setSecondPage()
|
|||
break;
|
||||
}
|
||||
|
||||
if( IsGithubPlugin() )
|
||||
{
|
||||
#ifdef KICAD_USE_WEBKIT
|
||||
m_buttonAddLib->SetLabel( _("Add Libs with WebViewer") );
|
||||
#else
|
||||
m_buttonAddLib->SetLabel( _("Add FP Library entry") );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
m_buttonAddLib->SetLabel( _("Add FP Libraries") );
|
||||
|
||||
return m_currLibDescr!= NULL;
|
||||
}
|
||||
|
||||
|
@ -515,15 +538,15 @@ bool WIZARD_FPLIB_TABLE::setLastPage() // Init prms for the last wizard page
|
|||
{
|
||||
case ENV_VAR_PATH: // Choice = path relative env var
|
||||
case PROJECT_PATH: // Choice = path relative to the project
|
||||
m_currLibDescr->m_EnvVarName = GetSelectedEnvVar();
|
||||
m_currLibDescr->m_DefaultPath = GetSelectedEnvVarValue();
|
||||
m_currLibDescr->m_EnvVarName = getSelectedEnvVar();
|
||||
m_currLibDescr->m_DefaultPath = getSelectedEnvVarValue();
|
||||
m_currLibDescr->m_IsAbsolutePath = false;
|
||||
|
||||
m_textOption->SetLabel( wxString::Format( wxT("%s (%s)"),
|
||||
m_rbPathManagement->GetStringSelection().GetData(),
|
||||
GetSelectedEnvVar().GetData() ) );
|
||||
getSelectedEnvVar().GetData() ) );
|
||||
|
||||
m_textPath->SetLabel( GetSelectedEnvVarValue() );
|
||||
m_textPath->SetLabel( getSelectedEnvVarValue() );
|
||||
break;
|
||||
|
||||
case ABSOLUTE_PATH: // Choice = absolute path
|
||||
|
@ -548,7 +571,7 @@ void WIZARD_FPLIB_TABLE::OnAddFpLibs( wxCommandEvent& event )
|
|||
if( m_currLibDescr->m_IsFile )
|
||||
selectLibsFiles();
|
||||
else if( m_currLibDescr->m_IsGitHub )
|
||||
selectLibsGithub();
|
||||
selectLibsGithubWithWebViewer();
|
||||
else
|
||||
selectLibsFolders();
|
||||
|
||||
|
@ -708,7 +731,7 @@ extern int RunWebViewer( wxWindow * aParent, const wxString& aUrlOnStart,
|
|||
wxArrayString* aUrlListSelection = NULL );
|
||||
#endif
|
||||
|
||||
void WIZARD_FPLIB_TABLE::selectLibsGithub() // select a set of library on Github
|
||||
void WIZARD_FPLIB_TABLE::selectLibsGithubWithWebViewer() // select a set of library on Github
|
||||
{
|
||||
// A string array to store the URLs selected from the web viewer:
|
||||
wxArrayString urls;
|
||||
|
@ -721,17 +744,24 @@ void WIZARD_FPLIB_TABLE::selectLibsGithub() // select a set of library on Git
|
|||
defaultURL = wxT( "https://github.com/KiCad" );
|
||||
#ifdef KICAD_USE_WEBKIT
|
||||
RunWebViewer( this, defaultURL, &urls );
|
||||
installGithubLibsFromList( urls );
|
||||
#else
|
||||
urls.Add( defaultURL + wxT("newlibname.pretty") );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void WIZARD_FPLIB_TABLE::installGithubLibsFromList( wxArrayString& aUrlList )
|
||||
{
|
||||
// add the libs found in aUrlList, after calculating a nickname and
|
||||
// replacing the path by an env variable, if needed
|
||||
// Create the nickname: currently make it from the url
|
||||
wxArrayString filepaths;
|
||||
wxArrayString nicknames;
|
||||
|
||||
for( unsigned ii = 0; ii < urls.GetCount(); ii++ )
|
||||
for( unsigned ii = 0; ii < aUrlList.GetCount(); ii++ )
|
||||
{
|
||||
wxString urlstring( urls[ii] );
|
||||
wxString urlstring( aUrlList[ii] );
|
||||
|
||||
wxURI uri( urlstring );
|
||||
|
||||
|
@ -746,19 +776,19 @@ void WIZARD_FPLIB_TABLE::selectLibsGithub() // select a set of library on Git
|
|||
if( m_currLibDescr->m_IsAbsolutePath ||
|
||||
m_currLibDescr->m_DefaultPath.IsEmpty() )
|
||||
{
|
||||
filepaths.Add( urls[ii] ); // use the full URL
|
||||
filepaths.Add( aUrlList[ii] ); // use the full URL
|
||||
}
|
||||
else
|
||||
{
|
||||
wxString shortURI;
|
||||
if( urls[ii].Lower().StartsWith(
|
||||
if( aUrlList[ii].Lower().StartsWith(
|
||||
m_currLibDescr->m_DefaultPath.Lower(), &shortURI ) )
|
||||
{
|
||||
shortURI.Prepend( wxT("${") + m_currLibDescr->m_EnvVarName + wxT("}") );
|
||||
filepaths.Add( shortURI );
|
||||
}
|
||||
else // keep the full URL
|
||||
filepaths.Add( urls[ii] ); // use the full URL
|
||||
filepaths.Add( aUrlList[ii] ); // use the full URL
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -784,3 +814,132 @@ void WIZARD_FPLIB_TABLE::OnRemoveFpLibs( wxCommandEvent& event )
|
|||
|
||||
m_gridFpListLibs->SelectRow( m_gridFpListLibs->GetGridCursorRow() );
|
||||
}
|
||||
|
||||
#ifdef BUILD_GITHUB_PLUGIN
|
||||
#include <../github/github_getliblist.h>
|
||||
|
||||
void WIZARD_FPLIB_TABLE::OnGithubLibsList( wxCommandEvent& event )
|
||||
{
|
||||
wxArrayString liblist;
|
||||
getLibsListGithub( liblist );
|
||||
|
||||
if( liblist.GetCount() == 0 ) // No lib selected
|
||||
return;
|
||||
|
||||
if( IsKicadPlugin() )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
if( !downloadGithubLibsFromList( liblist, &msg ) )
|
||||
{
|
||||
wxMessageBox( msg );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
installGithubLibsFromList( liblist );
|
||||
}
|
||||
|
||||
void WIZARD_FPLIB_TABLE::getLibsListGithub( wxArrayString& aList )
|
||||
{
|
||||
wxBeginBusyCursor();
|
||||
GITHUB_GETLIBLIST getter( m_textCtrlGithubURL->GetValue() );
|
||||
wxEndBusyCursor();
|
||||
|
||||
wxArrayString fullList;
|
||||
getter.GetLibraryList( fullList );
|
||||
|
||||
wxArrayInt choices;
|
||||
wxString msg( _( "Urls detected as footprint .pretty libraries.\n"
|
||||
"Selected urls will be added to the current footprint library list" ) );
|
||||
|
||||
if( wxGetSelectedChoices( choices, msg,
|
||||
_( "Footprint libraries" ), fullList, this ) <= 0 )
|
||||
return;
|
||||
|
||||
// Add selected url in list
|
||||
for( unsigned ii = 0; ii < choices.GetCount(); ii++ )
|
||||
{
|
||||
wxString& url = fullList[choices[ii]];
|
||||
aList.Add( url );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Download the .pretty libraries found in aUrlLis and store them on disk
|
||||
// in a master folder
|
||||
bool WIZARD_FPLIB_TABLE::downloadGithubLibsFromList( wxArrayString& aUrlList,
|
||||
wxString * aErrorMessage )
|
||||
{
|
||||
wxString masterFolder;
|
||||
wxString default_path;
|
||||
wxGetEnv( FP_LIB_TABLE::GlobalPathEnvVariableName(), &default_path );
|
||||
|
||||
masterFolder = wxDirSelector( _("Output Folder" ),
|
||||
default_path, 0, wxDefaultPosition, this );
|
||||
|
||||
if( masterFolder.IsEmpty() ) // Aborted by user
|
||||
{
|
||||
if( aErrorMessage )
|
||||
*aErrorMessage = _( "Aborted" );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !wxDirExists( masterFolder ) )
|
||||
{
|
||||
if( aErrorMessage )
|
||||
aErrorMessage->Printf( _( "Folder '%s' does not exists" ),
|
||||
GetChars( masterFolder ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Display a progress bar to show the downlaod state
|
||||
wxProgressDialog pdlg( _("Download libraries"), wxEmptyString, aUrlList.GetCount() );
|
||||
|
||||
// Download libs:
|
||||
for( unsigned ii = 0; ii < aUrlList.GetCount(); ii++ )
|
||||
{
|
||||
wxString& libsrc_name = aUrlList[ii];
|
||||
wxString libdst_name;
|
||||
|
||||
// Extract the lib name from the full URL:
|
||||
wxURI url( libsrc_name );
|
||||
wxFileName fn( url.GetPath() );
|
||||
// Set our local path
|
||||
fn.SetPath( masterFolder );
|
||||
libdst_name = fn.GetFullPath();
|
||||
|
||||
if( !wxDirExists( libdst_name ) )
|
||||
wxMkdir( libdst_name );
|
||||
|
||||
pdlg.Update( ii, libsrc_name);
|
||||
|
||||
try
|
||||
{
|
||||
PLUGIN::RELEASER src( IO_MGR::PluginFind( IO_MGR::GITHUB ) );
|
||||
PLUGIN::RELEASER dst( IO_MGR::PluginFind( IO_MGR::KICAD ) );
|
||||
|
||||
wxArrayString footprints = src->FootprintEnumerate( libsrc_name );
|
||||
|
||||
for( unsigned i = 0; i < footprints.size(); ++i )
|
||||
{
|
||||
std::auto_ptr<MODULE> m( src->FootprintLoad( libsrc_name, footprints[i] ) );
|
||||
dst->FootprintSave( libdst_name, m.get() );
|
||||
// m is deleted here by auto_ptr.
|
||||
}
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
if( aErrorMessage )
|
||||
aErrorMessage->Printf( _("Error:\n'%s'\nwhile downloading library:\n'%s'"),
|
||||
GetChars( ioe.errorText ), GetChars( libsrc_name ) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -112,13 +112,38 @@ public:
|
|||
|
||||
private:
|
||||
void initDlg( wxArrayString& aEnvVariableList );
|
||||
wxString GetSelectedEnvVar(); // return the selected env variable
|
||||
wxString GetSelectedEnvVarValue(); // return the selected env variable value
|
||||
wxString getSelectedEnvVar(); // return the selected env variable
|
||||
wxString getSelectedEnvVarValue(); // return the selected env variable value
|
||||
bool setSecondPage(); // Init prms for the second wizard page
|
||||
bool setLastPage(); // Init prms for the last wizard page
|
||||
void selectLibsFiles(); // select a set of library files
|
||||
void selectLibsFolders(); // select a set of library folders
|
||||
void selectLibsGithub(); // select a set of library on Github
|
||||
|
||||
/** select a set of library on Github, using the Web viewer to explore
|
||||
* the repos
|
||||
*/
|
||||
void selectLibsGithubWithWebViewer();
|
||||
|
||||
/** Get the list of .pretty libraries on Github,
|
||||
* without using the viewer, from the lib list extracted from the KiCad repos
|
||||
*/
|
||||
void getLibsListGithub( wxArrayString& aList );
|
||||
|
||||
/** Helper function.
|
||||
* add the .pretty libraries found in aUrlList, after calculating a nickname and
|
||||
* replacing the path by an env variable, if allowed and possible
|
||||
*/
|
||||
void installGithubLibsFromList( wxArrayString& aUrlList );
|
||||
|
||||
/**
|
||||
* Download the .pretty libraries found in aUrlLis and store them on disk
|
||||
* in a master folder
|
||||
* @return true if OK, false on error
|
||||
* @param aUrlList is the list of Github .pretty libs to download
|
||||
* @param aErrorMessage is a wxString pointer to store error messages if any.
|
||||
*/
|
||||
bool downloadGithubLibsFromList( wxArrayString& aUrlList, wxString * aErrorMessage = NULL );
|
||||
|
||||
void updateFromPlugingChoice(); // update dialog options and widgets
|
||||
// depending on the plugin choice
|
||||
int GetEnvVarCount() // Get the number of rows in env var table
|
||||
|
@ -136,6 +161,12 @@ private:
|
|||
return m_rbFpLibFormat->GetSelection() == GITHUB_PLUGIN;
|
||||
}
|
||||
|
||||
|
||||
bool IsKicadPlugin() // Helper funct, return true if
|
||||
{ // the Kicad plugin is the choice
|
||||
return m_rbFpLibFormat->GetSelection() == KICAD_PLUGIN;
|
||||
}
|
||||
|
||||
int HasGithubEnvVarCompatible(); // Return the first index to one env var
|
||||
// which defines a url compatible github
|
||||
// or -1 if not found
|
||||
|
@ -156,6 +187,9 @@ private:
|
|||
void OnPathManagementSelection( wxCommandEvent& event );
|
||||
void OnSelectEnvVarCell( wxGridEvent& event );
|
||||
void OnPluginSelection( wxCommandEvent& event );
|
||||
#ifdef BUILD_GITHUB_PLUGIN
|
||||
void OnGithubLibsList( wxCommandEvent& event );
|
||||
#endif
|
||||
bool ValidateOptions();
|
||||
};
|
||||
|
||||
|
|
|
@ -200,6 +200,9 @@ WIZARD_FPLIB_TABLE_BASE::WIZARD_FPLIB_TABLE_BASE( wxWindow* parent, wxWindowID i
|
|||
wxBoxSizer* bSizer5;
|
||||
bSizer5 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_buttonGithubLibList = new wxButton( m_wizPage3, wxID_ANY, _("Github Libs List"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer5->Add( m_buttonGithubLibList, 0, wxALL, 5 );
|
||||
|
||||
m_buttonAddLib = new wxButton( m_wizPage3, wxID_ANY, _("Add FP Libraries"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer5->Add( m_buttonAddLib, 0, wxALL, 5 );
|
||||
|
||||
|
@ -231,6 +234,7 @@ WIZARD_FPLIB_TABLE_BASE::WIZARD_FPLIB_TABLE_BASE( wxWindow* parent, wxWindowID i
|
|||
m_gridEnvironmentVariablesList->Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WIZARD_FPLIB_TABLE_BASE::OnSelectEnvVarCell ), NULL, this );
|
||||
m_buttonAddEV->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnAddEVariable ), NULL, this );
|
||||
m_buttonRemoveEV->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnRemoveEVariable ), NULL, this );
|
||||
m_buttonGithubLibList->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnGithubLibsList ), NULL, this );
|
||||
m_buttonAddLib->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnAddFpLibs ), NULL, this );
|
||||
m_buttonRemoveLib->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnRemoveFpLibs ), NULL, this );
|
||||
}
|
||||
|
@ -246,6 +250,7 @@ WIZARD_FPLIB_TABLE_BASE::~WIZARD_FPLIB_TABLE_BASE()
|
|||
m_gridEnvironmentVariablesList->Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WIZARD_FPLIB_TABLE_BASE::OnSelectEnvVarCell ), NULL, this );
|
||||
m_buttonAddEV->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnAddEVariable ), NULL, this );
|
||||
m_buttonRemoveEV->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnRemoveEVariable ), NULL, this );
|
||||
m_buttonGithubLibList->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnGithubLibsList ), NULL, this );
|
||||
m_buttonAddLib->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnAddFpLibs ), NULL, this );
|
||||
m_buttonRemoveLib->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnRemoveFpLibs ), NULL, this );
|
||||
|
||||
|
|
|
@ -1942,6 +1942,94 @@
|
|||
<property name="name">bSizer5</property>
|
||||
<property name="orient">wxHORIZONTAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxButton" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default">0</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Github Libs List</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_buttonGithubLibList</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnButtonClick">OnGithubLibsList</event>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
<event name="OnLeaveWindow"></event>
|
||||
<event name="OnLeftDClick"></event>
|
||||
<event name="OnLeftDown"></event>
|
||||
<event name="OnLeftUp"></event>
|
||||
<event name="OnMiddleDClick"></event>
|
||||
<event name="OnMiddleDown"></event>
|
||||
<event name="OnMiddleUp"></event>
|
||||
<event name="OnMotion"></event>
|
||||
<event name="OnMouseEvents"></event>
|
||||
<event name="OnMouseWheel"></event>
|
||||
<event name="OnPaint"></event>
|
||||
<event name="OnRightDClick"></event>
|
||||
<event name="OnRightDown"></event>
|
||||
<event name="OnRightUp"></event>
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL</property>
|
||||
|
|
|
@ -61,6 +61,7 @@ class WIZARD_FPLIB_TABLE_BASE : public wxWizard
|
|||
wxStaticText* m_textPath;
|
||||
wxStaticText* m_staticText2;
|
||||
wxGrid* m_gridFpListLibs;
|
||||
wxButton* m_buttonGithubLibList;
|
||||
wxButton* m_buttonAddLib;
|
||||
wxButton* m_buttonRemoveLib;
|
||||
|
||||
|
@ -73,6 +74,7 @@ class WIZARD_FPLIB_TABLE_BASE : public wxWizard
|
|||
virtual void OnSelectEnvVarCell( wxGridEvent& event ) { event.Skip(); }
|
||||
virtual void OnAddEVariable( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnRemoveEVariable( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnGithubLibsList( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnAddFpLibs( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnRemoveFpLibs( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
|
|
@ -635,14 +635,15 @@ static void export_vrml_pcbtext( MODEL_VRML& aModel, TEXTE_PCB* text )
|
|||
|
||||
if( text->IsMultilineAllowed() )
|
||||
{
|
||||
wxArrayString* list = wxStringSplit( text->GetShownText(), '\n' );
|
||||
wxArrayString strings_list;
|
||||
wxStringSplit( text->GetShownText(), strings_list, '\n' );
|
||||
std::vector<wxPoint> positions;
|
||||
positions.reserve( list->Count() );
|
||||
text->GetPositionsOfLinesOfMultilineText( positions, list->Count() );
|
||||
positions.reserve( strings_list.Count() );
|
||||
text->GetPositionsOfLinesOfMultilineText( positions, strings_list.Count() );
|
||||
|
||||
for( unsigned ii = 0; ii < list->Count(); ii++ )
|
||||
for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
|
||||
{
|
||||
wxString txt = list->Item( ii );
|
||||
wxString& txt = strings_list.Item( ii );
|
||||
DrawGraphicText( NULL, NULL, positions[ii], color,
|
||||
txt, text->GetOrientation(), size,
|
||||
text->GetHorizJustify(), text->GetVertJustify(),
|
||||
|
@ -650,8 +651,6 @@ static void export_vrml_pcbtext( MODEL_VRML& aModel, TEXTE_PCB* text )
|
|||
true,
|
||||
vrml_text_callback );
|
||||
}
|
||||
|
||||
delete (list);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -51,7 +51,7 @@ set( CMAKE_CXX_FLAGS
|
|||
"${CMAKE_CXX_FLAGS} -Wno-sign-compare -Wno-reorder -Wno-unused-variable -Wno-unused-function -Wno-strict-aliasing" )
|
||||
|
||||
set( GITHUB_PLUGIN_SRCS
|
||||
github_plugin.cpp
|
||||
github_plugin.cpp github_getliblist.cpp
|
||||
)
|
||||
|
||||
add_library( github_plugin STATIC ${GITHUB_PLUGIN_SRCS} )
|
||||
|
|
|
@ -0,0 +1,196 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2015 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* While creating a wizard to edit the fp lib tables, and mainly the web viewer
|
||||
* which can read the list of pretty library on a github repos, I was told there is
|
||||
* this URL to retrieve info from any particular repo:
|
||||
*
|
||||
* https://api.github.com/orgs/KiCad/repos
|
||||
* or
|
||||
* https://api.github.com/users/KiCad/repos
|
||||
*
|
||||
* This gets just information on the repo in JSON format.
|
||||
*
|
||||
* I used avhttp, already used in the pcbnew Github plugin to download
|
||||
* the json file.
|
||||
*
|
||||
* JP Charras.
|
||||
*/
|
||||
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* FIX ME
|
||||
* I do not include avhttp.hpp here, because it is already included in
|
||||
* github_plugin.cpp
|
||||
* and if it is also included in this file, the link fails (double definiton of modules)
|
||||
* therefore, the GITHUB_GETLIBLIST method which uses avhttp to download dats from gitub
|
||||
* is in github_plugin.cpp
|
||||
*/
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
// when WIN32_LEAN_AND_MEAN is defined, some useless includes in <window.h>
|
||||
// are skipped, and this avoid some compil issues
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
// defines needed by avhttp
|
||||
// Minimal Windows version is XP: Google for _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#define WINVER 0x0501
|
||||
#endif
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <avhttp.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
#include <wx/uri.h>
|
||||
|
||||
#include <github_getliblist.h>
|
||||
#include <macros.h>
|
||||
#include <common.h>
|
||||
|
||||
|
||||
GITHUB_GETLIBLIST::GITHUB_GETLIBLIST( const wxString& aRepoURL )
|
||||
{
|
||||
m_repoURL = aRepoURL;
|
||||
}
|
||||
|
||||
|
||||
bool GITHUB_GETLIBLIST::GetLibraryList( wxArrayString& aList )
|
||||
{
|
||||
std::string fullURLCommand;
|
||||
int page = 1;
|
||||
int itemCountMax = 99; // Do not use a valu > 100, it does not work
|
||||
|
||||
// Github max items returned is 100 per page
|
||||
|
||||
if( !repoURL2listURL( m_repoURL, &fullURLCommand, itemCountMax, page ) )
|
||||
{
|
||||
wxString msg = wxString::Format( _( "malformed URL:\n'%s'" ), GetChars( m_repoURL ) );
|
||||
wxMessageBox( msg );
|
||||
return false;
|
||||
}
|
||||
|
||||
// The URL lib names are relative to the server name.
|
||||
// so add the server name to them.
|
||||
wxURI repo( m_repoURL );
|
||||
wxString urlPrefix = wxT( "https://" ) + repo.GetServer() + wxT( "/" );;
|
||||
|
||||
wxString errorMsg;
|
||||
const char sep = ','; // Separator fields, in json returned file
|
||||
wxString tmp;
|
||||
int items_count_per_page = 0;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
bool success = remote_get_json( &fullURLCommand, &errorMsg );
|
||||
|
||||
if( !success )
|
||||
{
|
||||
wxMessageBox( errorMsg );
|
||||
return false;
|
||||
}
|
||||
|
||||
for( unsigned ii = 0; ii < m_json_image.size(); ii++ )
|
||||
{
|
||||
if( m_json_image[ii] == sep || ii == m_json_image.size() - 1 )
|
||||
{
|
||||
if( tmp.StartsWith( wxT( "\"full_name\"" ) ) )
|
||||
{
|
||||
#define QUOTE '\"'
|
||||
// Remove useless quotes:
|
||||
if( tmp[tmp.Length() - 1] == QUOTE )
|
||||
tmp.RemoveLast();
|
||||
|
||||
if( tmp.EndsWith( wxT( ".pretty" ) ) )
|
||||
{
|
||||
aList.Add( tmp.AfterLast( ':' ) );
|
||||
int idx = aList.GetCount() - 1;
|
||||
|
||||
if( aList[idx][0] == QUOTE )
|
||||
aList[idx].Remove( 0, 1 );
|
||||
|
||||
aList[idx].Prepend( urlPrefix );
|
||||
}
|
||||
|
||||
items_count_per_page++;
|
||||
}
|
||||
|
||||
tmp.Clear();
|
||||
}
|
||||
else
|
||||
tmp << m_json_image[ii];
|
||||
}
|
||||
|
||||
if( items_count_per_page >= itemCountMax )
|
||||
{
|
||||
page++;
|
||||
repoURL2listURL( m_repoURL, &fullURLCommand, itemCountMax, page );
|
||||
items_count_per_page = 0;
|
||||
m_json_image.clear();
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
aList.Sort();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool GITHUB_GETLIBLIST::repoURL2listURL( const wxString& aRepoURL,
|
||||
std::string* aFullURLCommand,
|
||||
int aItemCountMax, int aPage )
|
||||
{
|
||||
// aListURL is e.g. "https://api.github.com/orgs/KiCad/repos"
|
||||
// or "https://api.github.com/users/KiCad/repos"
|
||||
// aRepoURL is e.g. "https://github.com/KiCad"
|
||||
// Github has a default pagination set to 30 items.
|
||||
// but allows up to 100 items max if we add the "?per_page=100" option
|
||||
|
||||
wxURI repo( aRepoURL );
|
||||
|
||||
if( repo.HasServer() && repo.HasPath() )
|
||||
{
|
||||
// goal: "https://api.github.com/orgs/KiCad"
|
||||
wxString target_url( wxT( "https://api.github.com/orgs" ) );
|
||||
target_url += repo.GetPath();
|
||||
target_url += wxT( "/repos" );
|
||||
|
||||
// Github has a default pagination set to 30 items.
|
||||
// but allows up to 100 items max. Use this limit
|
||||
target_url += wxString::Format( "?per_page=%d&page=%d", aItemCountMax, aPage );
|
||||
|
||||
*aFullURLCommand = target_url.utf8_str();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2015 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef GITHUB_GETLIBLIST_H_
|
||||
#define GITHUB_GETLIBLIST_H_
|
||||
|
||||
|
||||
/**
|
||||
* Class GITHUB_GETLIBLIST
|
||||
* implements a portion of pcbnew's PLUGIN interface to provide read only access
|
||||
* to a github repo to extract pretty footprints library list, in json format.
|
||||
*
|
||||
* this plugin simply reads in a zip file of the repo and unzips it from RAM as
|
||||
* needed. Therefore this "Github" plugin is <b>read only for accessing remote
|
||||
* at https://api.github.com/orgs/KiCad/repos</b>
|
||||
*/
|
||||
class GITHUB_GETLIBLIST
|
||||
{
|
||||
public:
|
||||
// -----<API>----------------------------------------------------------
|
||||
bool GetLibraryList( wxArrayString& aList );
|
||||
|
||||
// -----</API>---------------------------------------------------------
|
||||
|
||||
GITHUB_GETLIBLIST( const wxString& aRepoURL );
|
||||
~GITHUB_GETLIBLIST() {}
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Function repoURL2listURL
|
||||
* translates a repo URL to the URL name which gives the state of repos URL
|
||||
* as commonly seen on github.com
|
||||
*
|
||||
* @param aRepoURL points to the base of the repo.
|
||||
* @param aFullURLCommand is URL the full URL command (URL+options).
|
||||
* @param aItemCountMax is the max item count in apage,
|
||||
* and is 100 for github repo.
|
||||
* @param aPage is the page number, if there are more than one page in repo.
|
||||
* @return bool - true if @a aRepoULR was parseable, else false
|
||||
*/
|
||||
bool repoURL2listURL( const wxString& aRepoURL, std::string* aFullURLCommand,
|
||||
int aItemCountMax, int aPage = 1 );
|
||||
|
||||
/**
|
||||
* Function remote_get_json
|
||||
* Download a json text from a github repo. The text image
|
||||
* is received into the m_input_stream.
|
||||
* @param aFullURLCommand the full command, i.e. the url with options like
|
||||
* "https://api.github.com/users/KiCad/repos?per_page=100?page=1"
|
||||
* @param aMsgError a pointer to a wxString which can store an error message
|
||||
* @return true if OK, false if error (which an error message in *aMsgError
|
||||
*/
|
||||
bool remote_get_json( std::string* aFullURLCommand, wxString* aMsgError );
|
||||
|
||||
wxString m_github_path; ///< Something like https://api.github.com/orgs/KiCad
|
||||
std::string m_json_image; ///< image of the text file in its entirety.
|
||||
wxString m_repoURL; // the URL of the Github repo
|
||||
};
|
||||
|
||||
|
||||
#endif // GITHUB_GETLIBLIST_H_
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2013 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* Copyright (C) 2015 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -101,6 +101,7 @@ Vary: Accept-Encoding
|
|||
#include <class_module.h>
|
||||
#include <macros.h>
|
||||
#include <fp_lib_table.h> // ExpandSubstitutions()
|
||||
#include <github_getliblist.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -549,6 +550,57 @@ void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR )
|
|||
}
|
||||
}
|
||||
|
||||
// This GITHUB_GETLIBLIST method should not be here, but in github_getliblist.cpp!
|
||||
// However it is here just because we need to include <avhttp.hpp> to compile it.
|
||||
// and if we include avhttp in 2 .cpp files, the link fails becuse it detects duplicate
|
||||
// avhttp functions.
|
||||
// So until it is fixed, this code is here.
|
||||
bool GITHUB_GETLIBLIST::remote_get_json( std::string* aFullURLCommand, wxString* aMsgError )
|
||||
{
|
||||
boost::asio::io_service io;
|
||||
avhttp::http_stream h( io );
|
||||
avhttp::request_opts options;
|
||||
|
||||
options.insert( "Accept", "application/json" );
|
||||
options.insert( "User-Agent", "http://kicad-pcb.org" ); // THAT WOULD BE ME.
|
||||
h.request_options( options );
|
||||
|
||||
try
|
||||
{
|
||||
std::ostringstream os;
|
||||
|
||||
h.open( *aFullURLCommand ); // only one file, therefore do it synchronously.
|
||||
os << &h;
|
||||
|
||||
// Keep json text file image in RAM.
|
||||
m_json_image = os.str();
|
||||
|
||||
// 4 lines, using SSL, top that.
|
||||
}
|
||||
catch( boost::system::system_error& e )
|
||||
{
|
||||
// https "GET" has faild, report this to API caller.
|
||||
static const char errorcmd[] = "https GET command failed"; // Do not translate this message
|
||||
|
||||
UTF8 fmt( _( "%s\nCannot get/download json data from: '%s'\nReason: '%s'" ) );
|
||||
|
||||
std::string msg = StrPrintf( fmt.c_str(),
|
||||
errorcmd,
|
||||
// Report secret list_url to user. The secret
|
||||
// list_url may go bad at some point in future if github changes
|
||||
// their server architecture. Then fix repoURL_zipURL() to reflect
|
||||
// new architecture.
|
||||
aFullURLCommand->c_str(), e.what() );
|
||||
|
||||
if( aMsgError )
|
||||
{
|
||||
*aMsgError = msg;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if 0 && defined(STANDALONE)
|
||||
|
||||
|
|
|
@ -469,20 +469,19 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte )
|
|||
if( pt_texte->IsMultilineAllowed() )
|
||||
{
|
||||
std::vector<wxPoint> positions;
|
||||
wxArrayString* list = wxStringSplit( shownText, '\n' );
|
||||
positions.reserve( list->Count() );
|
||||
wxArrayString strings_list;
|
||||
wxStringSplit( shownText, strings_list, '\n' );
|
||||
positions.reserve( strings_list.Count() );
|
||||
|
||||
pt_texte->GetPositionsOfLinesOfMultilineText( positions, list->Count() );
|
||||
pt_texte->GetPositionsOfLinesOfMultilineText( positions, strings_list.Count() );
|
||||
|
||||
for( unsigned ii = 0; ii < list->Count(); ii++ )
|
||||
for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
|
||||
{
|
||||
wxString& txt = list->Item( ii );
|
||||
wxString& txt = strings_list.Item( ii );
|
||||
m_plotter->Text( positions[ii], UNSPECIFIED_COLOR, txt, orient, size,
|
||||
pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(),
|
||||
thickness, pt_texte->IsItalic(), allow_bold );
|
||||
}
|
||||
|
||||
delete list;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue