Commit 392e3a0a authored by Henner Zeller's avatar Henner Zeller Committed by Wayne Stambaugh

Eeschema component selection dialog improvements.

* Allow to select units in components that have more than one right in the
  component chooser dialog.
* Keep chosen unit in history.
* Show preview of current component unit as thumbnail image next to the
  description box.
* Fixes lp:1280567
parent 7da13137
......@@ -21,11 +21,13 @@
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef COMPONENT_TREE_SEARCH_CONTAINER_H
#define COMPONENT_TREE_SEARCH_CONTAINER_H
#include <vector>
#include <wx/string.h>
class LIB_COMPONENT;
class LIB_ALIAS;
class CMP_LIBRARY;
class wxTreeCtrl;
class wxArrayString;
......@@ -44,7 +46,7 @@ public:
~COMPONENT_TREE_SEARCH_CONTAINER();
/** Function AddLibrary
* Add the components of this library to be searched.
* Add all the components and their aliases of this library to be searched.
* To be called in the setup phase to fill this container.
*
* @param aLib containting all the components to be added.
......@@ -56,19 +58,19 @@ public:
* To be called in the setup phase to fill this container.
*
* @param aNodeName The parent node name the components will show up as leaf.
* @param aComponentNameList List of component names.
* @param aAliasNameList List of alias names.
* @param aOptionalLib Library to look up the component names (if NULL: global lookup)
* @param aNormallyExpanded Should the node in the tree be expanded by default.
*/
void AddComponentList( const wxString& aNodeName, const wxArrayString& aComponentNameList,
CMP_LIBRARY* aOptionalLib, bool aNormallyExpanded );
void AddAliasList( const wxString& aNodeName, const wxArrayString& aAliasNameList,
CMP_LIBRARY* aOptionalLib );
/** Function SetPreselectNode
* Set the component name to be selected in absence of any search-result.
*
* @param aComponentName the component name to be selected.
* @param aUnit the component unit to be selected (if > 0).
*/
void SetPreselectNode( const wxString& aComponentName );
void SetPreselectNode( const wxString& aComponentName, int aUnit );
/** Function SetTree
* Set the tree to be manipulated.
......@@ -92,17 +94,23 @@ public:
*/
void UpdateSearchTerm( const wxString& aSearch );
/** Function GetSelectedComponent
/** Function GetSelectedAlias
*
* @return the selected component or NULL if there is none.
* @param if not-NULL, the selected sub-unit is set here.
* @return the selected alias or NULL if there is none.
*/
LIB_COMPONENT* GetSelectedComponent();
LIB_ALIAS* GetSelectedAlias( int* aUnit );
private:
struct TREE_NODE;
static bool scoreComparator( const TREE_NODE* a1, const TREE_NODE* a2 );
std::vector<TREE_NODE*> nodes;
wxString preselect_node_name;
wxTreeCtrl* tree;
int libraries_added;
wxString preselect_node_name;
int preselect_unit_number;
};
#endif /* COMPONENT_TREE_SEARCH_CONTAINER_H */
......@@ -21,6 +21,8 @@
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef DIALOG_CHOOSE_COMPONENT_H
#define DIALOG_CHOOSE_COMPONENT_H
#include <dialog_choose_component_base.h>
......@@ -32,14 +34,16 @@ class DIALOG_CHOOSE_COMPONENT : public DIALOG_CHOOSE_COMPONENT_BASE
{
public:
DIALOG_CHOOSE_COMPONENT( wxWindow* aParent, const wxString& aTitle,
COMPONENT_TREE_SEARCH_CONTAINER* aSearch_container );
COMPONENT_TREE_SEARCH_CONTAINER* aSearch_container,
int aDeMorganConvert );
/** Function GetSelectedComponentName
/** Function GetSelectedAliasName
* To be called after this dialog returns from ShowModal().
*
* @return the component that has been selected, or an empty string if there is none.
* @param aUnit if not NULL, the selected unit is filled in here.
* @return the alias that has been selected, or an empty string if there is none.
*/
wxString GetSelectedComponentName() const;
wxString GetSelectedAliasName( int* aUnit ) const;
/** Function IsExternalBrowserSelected
*
......@@ -57,13 +61,18 @@ protected:
virtual void OnTreeMouseUp( wxMouseEvent& aMouseEvent );
virtual void OnStartComponentBrowser( wxMouseEvent& aEvent );
virtual void OnHandlePreviewRepaint( wxPaintEvent& aRepaintEvent );
private:
void updateSelection();
void SelectIfValid( const wxTreeItemId& aTreeId );
bool updateSelection();
void selectIfValid( const wxTreeItemId& aTreeId );
void renderPreview( LIB_COMPONENT* aComponent, int aUnit );
COMPONENT_TREE_SEARCH_CONTAINER* const m_search_container;
LIB_COMPONENT* m_selected_component;
const int m_deMorganConvert;
bool m_external_browser_requested;
bool m_received_doubleclick_in_tree;
bool m_ready_to_render;
};
#endif /* DIALOG_CHOOSE_COMPONENT_H */
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 6 2013)
// C++ code generated with wxFormBuilder (version Feb 8 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -11,7 +11,7 @@
DIALOG_CHOOSE_COMPONENT_BASE::DIALOG_CHOOSE_COMPONENT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxSize( 450,-1 ), wxDefaultSize );
this->SetSizeHints( wxSize( 450,100 ), wxDefaultSize );
wxBoxSizer* bSizer1;
bSizer1 = new wxBoxSizer( wxVERTICAL );
......@@ -37,35 +37,21 @@ DIALOG_CHOOSE_COMPONENT_BASE::DIALOG_CHOOSE_COMPONENT_BASE( wxWindow* parent, wx
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxHORIZONTAL );
m_componentView = new wxStaticText( this, wxID_ANY, wxT("TODO\n(mini. comp image)"), wxDefaultPosition, wxSize( 100,100 ), 0 );
m_componentView->Wrap( -1 );
m_componentView = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_componentView->SetMinSize( wxSize( 100,100 ) );
bSizer3->Add( m_componentView, 0, wxALL, 5 );
bSizer3->Add( m_componentView, 1, wxEXPAND | wxALL, 5 );
wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxVERTICAL );
m_componentDetails = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), wxTE_MULTILINE );
m_componentDetails->SetMinSize( wxSize( -1,100 ) );
m_componentDetails = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,100 ), wxTE_MULTILINE );
bSizer6->Add( m_componentDetails, 1, wxALL|wxEXPAND, 5 );
m_unitChoice = new wxComboBox( this, wxID_ANY, wxT("Unit A"), wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_unitChoice->Enable( false );
m_unitChoice->Hide();
bSizer6->Add( m_unitChoice, 0, wxALL, 5 );
bSizer3->Add( bSizer6, 2, wxEXPAND, 5 );
bSizer3->Add( m_componentDetails, 2, wxALL|wxEXPAND, 5 );
bSizer1->Add( bSizer3, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer5;
bSizer5 = new wxBoxSizer( wxHORIZONTAL );
bSizer5->Add( 0, 0, 1, wxEXPAND, 5 );
bSizer5 = new wxBoxSizer( wxVERTICAL );
m_button = new wxStdDialogButtonSizer();
m_buttonOK = new wxButton( this, wxID_OK );
......@@ -77,7 +63,7 @@ DIALOG_CHOOSE_COMPONENT_BASE::DIALOG_CHOOSE_COMPONENT_BASE( wxWindow* parent, wx
bSizer5->Add( m_button, 0, wxEXPAND, 5 );
bSizer1->Add( bSizer5, 0, wxEXPAND, 5 );
bSizer1->Add( bSizer5, 0, wxALIGN_RIGHT, 5 );
this->SetSizer( bSizer1 );
......@@ -92,7 +78,6 @@ DIALOG_CHOOSE_COMPONENT_BASE::DIALOG_CHOOSE_COMPONENT_BASE( wxWindow* parent, wx
m_libraryComponentTree->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnTreeMouseUp ), NULL, this );
m_libraryComponentTree->Connect( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, wxTreeEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnDoubleClickTreeSelect ), NULL, this );
m_libraryComponentTree->Connect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnTreeSelect ), NULL, this );
m_componentView->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnStartComponentBrowser ), NULL, this );
}
DIALOG_CHOOSE_COMPONENT_BASE::~DIALOG_CHOOSE_COMPONENT_BASE()
......@@ -104,6 +89,5 @@ DIALOG_CHOOSE_COMPONENT_BASE::~DIALOG_CHOOSE_COMPONENT_BASE()
m_libraryComponentTree->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnTreeMouseUp ), NULL, this );
m_libraryComponentTree->Disconnect( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, wxTreeEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnDoubleClickTreeSelect ), NULL, this );
m_libraryComponentTree->Disconnect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnTreeSelect ), NULL, this );
m_componentView->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_CHOOSE_COMPONENT_BASE::OnStartComponentBrowser ), NULL, this );
}
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 6 2013)
// C++ code generated with wxFormBuilder (version Feb 8 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -22,7 +22,7 @@ class DIALOG_SHIM;
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/treectrl.h>
#include <wx/combobox.h>
#include <wx/panel.h>
#include <wx/button.h>
#include <wx/dialog.h>
......@@ -40,9 +40,8 @@ class DIALOG_CHOOSE_COMPONENT_BASE : public DIALOG_SHIM
wxStaticText* m_searchLabel;
wxTextCtrl* m_searchBox;
wxTreeCtrl* m_libraryComponentTree;
wxStaticText* m_componentView;
wxPanel* m_componentView;
wxTextCtrl* m_componentDetails;
wxComboBox* m_unitChoice;
wxStdDialogButtonSizer* m_button;
wxButton* m_buttonOK;
wxButton* m_buttonCancel;
......@@ -54,7 +53,6 @@ class DIALOG_CHOOSE_COMPONENT_BASE : public DIALOG_SHIM
virtual void OnTreeMouseUp( wxMouseEvent& event ) { event.Skip(); }
virtual void OnDoubleClickTreeSelect( wxTreeEvent& event ) { event.Skip(); }
virtual void OnTreeSelect( wxTreeEvent& event ) { event.Skip(); }
virtual void OnStartComponentBrowser( wxMouseEvent& event ) { event.Skip(); }
public:
......
......@@ -81,6 +81,7 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( void )
wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
wxArrayString& aHistoryList,
int& aHistoryLastUnit,
bool aUseLibBrowser,
int* aUnit,
int* aConvert )
......@@ -113,17 +114,18 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
{
// This is good for a transition for experineced users: giving them a History. Ideally,
// we actually make this part even faster to access with a popup on ALT-a or something.
search_container.AddComponentList( _("-- History --"), aHistoryList, NULL, true );
search_container.SetPreselectNode( aHistoryList[0] );
search_container.AddAliasList( _("-- History --"), aHistoryList, NULL );
search_container.SetPreselectNode( aHistoryList[0], aHistoryLastUnit );
}
const int deMorgan = aConvert ? *aConvert : 1;
dialogTitle.Printf( _( "Choose Component (%d items loaded)" ), cmpCount );
DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, &search_container );
DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, &search_container, deMorgan );
if( dlg.ShowModal() == wxID_CANCEL )
return wxEmptyString;
wxString cmpName = dlg.GetSelectedComponentName();
wxString cmpName = dlg.GetSelectedAliasName( aUnit );
if( dlg.IsExternalBrowserSelected() )
{
......@@ -137,7 +139,10 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
}
if ( !cmpName.empty() )
{
AddHistoryComponentName( aHistoryList, cmpName );
if ( aUnit ) aHistoryLastUnit = *aUnit;
}
return cmpName;
}
......@@ -146,6 +151,7 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aDC,
const wxString& aLibname,
wxArrayString& aHistoryList,
int& aHistoryLastUnit,
bool aUseLibBrowser )
{
int unit = 1;
......@@ -153,8 +159,8 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aDC,
SetRepeatItem( NULL );
m_canvas->SetIgnoreMouseEvents( true );
wxString Name = SelectComponentFromLibrary( aLibname, aHistoryList, aUseLibBrowser,
&unit, &convert );
wxString Name = SelectComponentFromLibrary( aLibname, aHistoryList, aHistoryLastUnit,
aUseLibBrowser, &unit, &convert );
if( Name.IsEmpty() )
{
......
......@@ -447,16 +447,18 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
if( aColor >= 0 )
fill = NO_FILL;
EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL;
if( fill == FILLED_WITH_BG_BODYCOLOR )
{
GRFilledArc( aPanel->GetClipBox(), aDC, posc.x, posc.y, pt1, pt2,
GRFilledArc( clipbox, aDC, posc.x, posc.y, pt1, pt2,
m_Radius, GetPenSize( ),
(m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ),
GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
}
else if( fill == FILLED_SHAPE && !aData )
{
GRFilledArc( aPanel->GetClipBox(), aDC, posc.x, posc.y, pt1, pt2, m_Radius,
GRFilledArc( clipbox, aDC, posc.x, posc.y, pt1, pt2, m_Radius,
color, color );
}
else
......@@ -464,11 +466,11 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
#ifdef DRAW_ARC_WITH_ANGLE
GRArc( aPanel->GetClipBox(), aDC, posc.x, posc.y, pt1, pt2, m_Radius,
GRArc( clipbox, aDC, posc.x, posc.y, pt1, pt2, m_Radius,
GetPenSize(), color );
#else
GRArc1( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, pos2.x, pos2.y,
GRArc1( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y,
posc.x, posc.y, GetPenSize(), color );
#endif
}
......@@ -477,7 +479,7 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
* calculation. */
#if 0
EDA_RECT bBox = GetBoundingBox();
GRRect( aPanel->GetClipBox(), aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
GRRect( clipbox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
......
......@@ -231,20 +231,21 @@ void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
if( aColor >= 0 )
fill = NO_FILL;
EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL;
if( fill == FILLED_WITH_BG_BODYCOLOR )
GRFilledCircle( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, m_Radius, GetPenSize(),
GRFilledCircle( clipbox, aDC, pos1.x, pos1.y, m_Radius, GetPenSize(),
(m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ),
GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill == FILLED_SHAPE )
GRFilledCircle( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, m_Radius, 0, color, color );
GRFilledCircle( clipbox, aDC, pos1.x, pos1.y, m_Radius, 0, color, color );
else
GRCircle( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, m_Radius, GetPenSize(), color );
GRCircle( clipbox, aDC, pos1.x, pos1.y, m_Radius, GetPenSize(), color );
/* Set to one (1) to draw bounding box around circle to validate bounding
* box calculation. */
#if 0
EDA_RECT bBox = GetBoundingBox();
GRRect( aPanel->GetClipBox(), aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
GRRect( clipbox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
......
......@@ -296,15 +296,16 @@ void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint
GRSetDrawMode( aDC, aDrawMode );
EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL;
if( fill == FILLED_WITH_BG_BODYCOLOR )
GRPoly( aPanel->GetClipBox(), aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(),
GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(),
(m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ),
GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill == FILLED_SHAPE )
GRPoly( aPanel->GetClipBox(), aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(),
GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(),
color, color );
else
GRPoly( aPanel->GetClipBox(), aDC, m_PolyPoints.size(), buffer, 0, GetPenSize(),
GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 0, GetPenSize(),
color, color );
delete[] buffer;
......@@ -314,7 +315,7 @@ void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint
#if 0
EDA_RECT bBox = GetBoundingBox();
bBox.Inflate( m_Thickness + 1, m_Thickness + 1 );
GRRect( aPanel->GetClipBox(), aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
GRRect( clipbox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
......
......@@ -222,22 +222,23 @@ void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
GRSetDrawMode( aDC, aDrawMode );
EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL;
if( fill == FILLED_WITH_BG_BODYCOLOR && !aData )
GRFilledRect( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, pos2.x, pos2.y, GetPenSize( ),
GRFilledRect( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, GetPenSize( ),
(m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ),
GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( m_Fill == FILLED_SHAPE && !aData )
GRFilledRect( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, pos2.x, pos2.y,
GRFilledRect( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y,
GetPenSize(), color, color );
else
GRRect( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, pos2.x, pos2.y, GetPenSize(), color );
GRRect( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, GetPenSize(), color );
/* Set to one (1) to draw bounding box around rectangle to validate
* bounding box calculation. */
#if 0
EDA_RECT bBox = GetBoundingBox();
bBox.Inflate( m_Thickness + 1, m_Thickness + 1 );
GRRect( aPanel->GetClipBox(), aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
GRRect( clipbox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
......
......@@ -131,8 +131,10 @@ void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event )
return;
}
wxArrayString historyList;
CmpName = SelectComponentFromLibrary( m_library->GetName(), historyList, true, NULL, NULL );
wxArrayString dummyHistoryList;
int dummyLastUnit;
CmpName = SelectComponentFromLibrary( m_library->GetName(), dummyHistoryList, dummyLastUnit,
true, NULL, NULL );
if( CmpName.IsEmpty() )
return;
......
......@@ -46,8 +46,13 @@
#include <sch_bitmap.h>
// TODO(hzeller): These pairs of elmenets should be represented by an object, but don't want
// to refactor too much right now to not get in the way with other code changes.
static wxArrayString s_CmpNameList;
static int s_CmpLastUnit;
static wxArrayString s_PowerNameList;
static int s_LastPowerUnit;
void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
......@@ -294,7 +299,8 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case ID_SCH_PLACE_COMPONENT:
if( (item == NULL) || (item->GetFlags() == 0) )
{
GetScreen()->SetCurItem( Load_Component( aDC, wxEmptyString, s_CmpNameList, true ) );
GetScreen()->SetCurItem( Load_Component( aDC, wxEmptyString,
s_CmpNameList, s_CmpLastUnit, true ) );
m_canvas->SetAutoPanRequest( true );
}
else
......@@ -307,7 +313,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{
GetScreen()->SetCurItem( Load_Component( aDC, wxT( "power" ),
s_PowerNameList, false ) );
s_PowerNameList, s_LastPowerUnit, false ) );
m_canvas->SetAutoPanRequest( true );
}
else
......
......@@ -89,21 +89,24 @@ protected:
* Calls the library viewer to select component to import into schematic.
* if the library viewer is currently running, it is closed and reopened
* in modal mode.
* @param aLibname = the lib name or an empty string.
* @param aLibname the lib name or an empty string.
* if aLibname is empty, the full list of libraries is used
* @param aHistoryList = list of previously loaded components
* @param aUseLibBrowser = bool to call the library viewer to select the component
* @param aUnit = a point to int to return the selected unit (if any)
* @param aConvert = a point to int to return the selected De Morgan shape (if any)
* @param aHistoryList list of previously loaded components
* @param aHistoryLastUnit remembering last unit in last component.
* @param aUseLibBrowser bool to call the library viewer to select the component
* @param aUnit a pointer to int to return the selected unit (if any)
* @param aConvert a pointer to int to return the selected De Morgan shape (if any)
*
* @return the component name
*/
wxString SelectComponentFromLibrary( const wxString& aLibname,
wxArrayString& aHistoryList,
int& aHistoryLastUnit,
bool aUseLibBrowser,
int* aUnit,
int* aConvert );
/**
* Function OnOpenLibraryViewer
* Open the library viewer only to browse library contents.
......
......@@ -1001,10 +1001,16 @@ private:
* loads from a library and places a component.
* if libname != "", search in lib "libname"
* else search in all loaded libs
*
* @param aHistoryList list remembering recently used component names.
* @param aHistoryLastUnit remembering last unit in last component.
* (TODO(hzeller): This really should be a class doing history, but didn't
* want to change too much while other refactoring is going on)
*/
SCH_COMPONENT* Load_Component( wxDC* DC,
const wxString& libname,
wxArrayString& List,
wxArrayString& aHistoryList,
int& aHistoryLastUnit,
bool UseLibBrowser );
/**
......
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