diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index 75e085313b..fc7360eb3d 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -60,27 +60,17 @@ enum id_eeschema_frm ID_RESCUE_CACHED, ID_REMAP_SYMBOLS, - /* Schematic editor horizontal toolbar IDs */ - ID_ADD_PART_TO_SCHEMATIC, - /* Library editor horizontal toolbar IDs. */ - ID_LIBEDIT_SYNC_PIN_EDIT, ID_LIBEDIT_SELECT_PART_NUMBER, /* Library editor vertical toolbar IDs. */ ID_LIBEDIT_IMPORT_BODY_BUTT, ID_LIBEDIT_EXPORT_BODY_BUTT, - /* Library editor menubar IDs */ - ID_LIBEDIT_GEN_PNG_FILE, - ID_LIBEDIT_GEN_SVG_FILE, - /* Library viewer horizontal toolbar IDs */ ID_LIBVIEW_SELECT_PART, ID_LIBVIEW_NEXT, ID_LIBVIEW_PREVIOUS, - ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, - ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, ID_LIBVIEW_SELECT_PART_NUMBER, ID_LIBVIEW_LIB_LIST, ID_LIBVIEW_CMP_LIST, diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index a64dd32644..296a665593 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -83,10 +83,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_CLOSE( LIB_EDIT_FRAME::OnCloseWindow ) EVT_SIZE( LIB_EDIT_FRAME::OnSize ) - // Main horizontal toolbar. - EVT_TOOL( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::OnSyncPinEditClick ) - EVT_TOOL( ID_ADD_PART_TO_SCHEMATIC, LIB_EDIT_FRAME::OnAddPartToSchematic ) - EVT_COMBOBOX( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnSelectUnit ) // Right vertical toolbar. @@ -98,7 +94,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings ) // Update user interface elements. - EVT_UPDATE_UI( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::OnUpdateSyncPinEdit ) EVT_UPDATE_UI( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnUpdatePartNumber ) END_EVENT_TABLE() @@ -278,18 +273,18 @@ double LIB_EDIT_FRAME::BestZoom() void LIB_EDIT_FRAME::RebuildSymbolUnitsList() { - if( !m_partSelectBox ) + if( !m_unitSelectBox ) return; - if( m_partSelectBox->GetCount() != 0 ) - m_partSelectBox->Clear(); + if( m_unitSelectBox->GetCount() != 0 ) + m_unitSelectBox->Clear(); LIB_PART* part = GetCurPart(); if( !part || part->GetUnitCount() <= 1 ) { m_unit = 1; - m_partSelectBox->Append( wxEmptyString ); + m_unitSelectBox->Append( wxEmptyString ); } else { @@ -297,7 +292,7 @@ void LIB_EDIT_FRAME::RebuildSymbolUnitsList() { wxString sub = LIB_PART::SubReference( i+1, false ); wxString unit = wxString::Format( _( "Unit %s" ), GetChars( sub ) ); - m_partSelectBox->Append( unit ); + m_unitSelectBox->Append( unit ); } } @@ -306,7 +301,7 @@ void LIB_EDIT_FRAME::RebuildSymbolUnitsList() if( part && part->GetUnitCount() < m_unit ) m_unit = 1; - m_partSelectBox->SetSelection( ( m_unit > 0 ) ? m_unit - 1 : 0 ); + m_unitSelectBox->SetSelection(( m_unit > 0 ) ? m_unit - 1 : 0 ); } @@ -336,24 +331,16 @@ void LIB_EDIT_FRAME::ThawSearchTree() } -void LIB_EDIT_FRAME::OnUpdateSyncPinEdit( wxUpdateUIEvent& event ) -{ - LIB_PART* part = GetCurPart(); - event.Enable( part && part->IsMulti() && !part->UnitsLocked() ); - event.Check( m_SyncPinEdit ); -} - - void LIB_EDIT_FRAME::OnUpdatePartNumber( wxUpdateUIEvent& event ) { - if( !m_partSelectBox ) + if( !m_unitSelectBox ) return; LIB_PART* part = GetCurPart(); // Using the typical event.Enable() call doesn't seem to work with wxGTK // so use the pointer to alias combobox to directly enable or disable. - m_partSelectBox->Enable( part && part->GetUnitCount() > 1 ); + m_unitSelectBox->Enable( part && part->GetUnitCount() > 1 ); } @@ -374,12 +361,6 @@ void LIB_EDIT_FRAME::OnSelectUnit( wxCommandEvent& event ) } -void LIB_EDIT_FRAME::OnSyncPinEditClick( wxCommandEvent& event ) -{ - m_SyncPinEdit = m_mainToolBar->GetToolToggled( ID_LIBEDIT_SYNC_PIN_EDIT ); -} - - wxString LIB_EDIT_FRAME::GetCurLib() const { wxString libNickname = Prj().GetRString( PROJECT::SCH_LIBEDIT_CUR_LIB ); @@ -476,33 +457,6 @@ bool LIB_EDIT_FRAME::SynchronizePins() } -void LIB_EDIT_FRAME::OnAddPartToSchematic( wxCommandEvent& event ) -{ - if( GetCurPart() ) - { - SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false ); - - if( !schframe ) // happens when the schematic editor is not active (or closed) - { - DisplayErrorMessage( this, _( "No schematic currently open." ) ); - return; - } - - SCH_COMPONENT* component = new SCH_COMPONENT( *GetCurPart(), GetCurPart()->GetLibId(), - g_CurrentSheet, GetUnit(), GetConvert() ); - - // Be sure the link to the corresponding LIB_PART is OK: - component->Resolve( *Prj().SchSymbolLibTable() ); - - if( schframe->GetAutoplaceFields() ) - component->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false ); - - schframe->Raise(); - schframe->GetToolManager()->RunAction( EE_ACTIONS::placeSymbol, true, component ); - } -} - - void LIB_EDIT_FRAME::refreshSchematic() { // There may be no parent window so use KIWAY message to refresh the schematic editor diff --git a/eeschema/libedit/lib_edit_frame.h b/eeschema/libedit/lib_edit_frame.h index d7b7416b7f..5d27375d13 100644 --- a/eeschema/libedit/lib_edit_frame.h +++ b/eeschema/libedit/lib_edit_frame.h @@ -50,33 +50,27 @@ class LIB_MANAGER; */ class LIB_EDIT_FRAME : public SCH_BASE_FRAME { - LIB_PART* m_my_part; ///< a part I own, it is not in any library, but a copy could be. - wxComboBox* m_partSelectBox; ///< a Box to select a part to edit (if any) - SYMBOL_TREE_PANE* m_treePane; ///< component search tree widget - LIB_MANAGER* m_libMgr; ///< manager taking care of temporary modificatoins + LIB_PART* m_my_part; // a part I own, it is not in any library, but a copy + // could be. + wxComboBox* m_unitSelectBox; // a ComboBox to select a unit to edit (if the part + // has multiple units) + SYMBOL_TREE_PANE* m_treePane; // component search tree widget + LIB_MANAGER* m_libMgr; // manager taking care of temporary modificatoins // The unit number to edit and show int m_unit; - // Show the normal shape ( m_convert <= 1 ) or the converted shape - // ( m_convert > 1 ) + // Show the normal shape ( m_convert <= 1 ) or the converted shape ( m_convert > 1 ) int m_convert; - // true to force DeMorgan/normal tools selection enabled. - // They are enabled when the loaded component has - // Graphic items for converted shape - // But under some circumstances (New component created) - // these tools must left enabled + // True to force DeMorgan/normal tools selection enabled. + // They are enabled when the loaded component has graphic items for converted shape + // But under some circumstances (New component created) these tools must left enabled static bool m_showDeMorgan; - /// The default pin num text size setting. - static int m_textPinNumDefaultSize; - - /// The default pin name text size setting. - static int m_textPinNameDefaultSize; - - /// Default pin length - static int m_defaultPinLength; + static int m_textPinNumDefaultSize; // The default pin num text size setting. + static int m_textPinNameDefaultSize; // The default pin name text size setting. + static int m_defaultPinLength; // Default pin length /// Default repeat offset for pins in repeat place pin int m_repeatPinStep; @@ -85,25 +79,24 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME public: /** - * Set to true to not synchronize pins at the same position when editing - * symbols with multiple units or multiple body styles. - * Therefore deleting, moving pins are made for all pins at the same location - * When units are interchangeable, synchronizing editing of pins is usually - * the best way, because if units are interchangeable, it imply all similar - * pins are on the same location. - * When units are non interchangeable, do not synchronize editing of pins, because - * each part is specific, and there are no similar pins between units. + * Set to true to synchronize pins at the same position when editing symbols with multiple + * units or multiple body styles. Deleting or moving pins will affect all pins at the same + * location. + * When units are interchangeable, synchronizing editing of pins is usually the best way, + * because if units are interchangeable, it implies that all similar pins are at the same + * location. + * When units are not interchangeable, do not synchronize editing of pins, because each part + * is specific, and there are no (or few) similar pins between units. * - * Setting this to false allows editing each pin per part or body style - * regardless other pins at the same location. - * This requires the user to open each part or body style to make changes - * to the other pins at the same location. - * To know if others pins must be coupled when editing a pin, use - * SynchronizePins() instead of m_syncPinEdit, because SynchronizePins() - * is more reliable (takes in account the fact units are interchangeable, - * there are more than one unit). + * Setting this to false allows editing each pin per part or body style regardless other + * pins at the same location. This requires the user to open each part or body style to make + * changes to the other pins at the same location. + * + * To know if others pins must be coupled when editing a pin, use SynchronizePins() instead + * of m_syncPinEdit, because SynchronizePins() is more reliable (takes in account the fact + * units are interchangeable, there are more than one unit). */ - bool m_SyncPinEdit; + bool m_SyncPinEdit; /** Convert of the item currently being drawn. */ bool m_DrawSpecificConvert; @@ -111,8 +104,8 @@ public: /** * Specify which component parts the current draw item applies to. * - * If true, the item being drawn or edited applies only to the selected - * part. Otherwise it applies to all parts in the component. + * If true, the item being drawn or edited applies only to the selected part. Otherwise + * it applies to all parts in the component. */ bool m_DrawSpecificUnit; @@ -134,8 +127,8 @@ public: /** * Check if any pending libraries have been modified. * - * This only checks for modified libraries. If a new symbol was created and - * modified and no libraries have been modified, the return value will be false. + * This only checks for modified libraries. If a new symbol was created and modified + * and no libraries have been modified, the return value will be false. * * @return True if there are any pending library modifications. */ @@ -164,18 +157,12 @@ public: */ void SetCurPart( LIB_PART* aPart ); - /** @return the default pin num text size. - */ static int GetPinNumDefaultSize() { return m_textPinNumDefaultSize; } static void SetPinNumDefaultSize( int aSize ) { m_textPinNumDefaultSize = aSize; } - /** @return The default pin name text size setting. - */ static int GetPinNameDefaultSize() { return m_textPinNameDefaultSize; } static void SetPinNameDefaultSize( int aSize ) { m_textPinNameDefaultSize = aSize; } - /** @return The default pin len setting. - */ static int GetDefaultPinLength() { return m_defaultPinLength; } static void SetDefaultPinLength( int aLength ) { m_defaultPinLength = aLength; } @@ -187,18 +174,9 @@ public: void ReCreateMenuBar() override; - /** - * Pin editing (add, delete, move...) can be synchronized between units - * when units are interchangeable because in this case similar pins are expected - * at the same location - * @return true if the edit pins separately option is false and the current symbol - * has multiple interchengeable units. - * Otherwise return false. - */ + // See comments for m_SyncPinEdit. bool SynchronizePins(); - void OnSyncPinEditClick( wxCommandEvent& event ); - void OnImportBody( wxCommandEvent& aEvent ); void OnExportBody( wxCommandEvent& aEvent ); @@ -215,11 +193,6 @@ public: void ImportPart(); void ExportPart(); - /** - * Add the current part to the schematic - */ - void OnAddPartToSchematic( wxCommandEvent& event ); - /** * Saves the selected part or library. */ @@ -260,7 +233,6 @@ public: void FreezeSearchTree(); void ThawSearchTree(); - void OnUpdateSyncPinEdit( wxUpdateUIEvent& event ); void OnUpdatePartNumber( wxUpdateUIEvent& event ); void UpdateAfterSymbolProperties( wxString* aOldName, wxArrayString* aOldAliases ); @@ -330,8 +302,8 @@ private: /** * Set the current active library to \a aLibrary. * - * @param aLibrary the nickname of the library in the symbol library table. If wxEmptyString, - * then display list of available libraries to select from. + * @param aLibrary the nickname of the library in the symbol library table. If empty, + * display list of available libraries to select from. */ void SelectActiveLibrary( const wxString& aLibrary = wxEmptyString ); @@ -346,8 +318,8 @@ private: wxString SelectLibraryFromList(); /** - * Loads a symbol from the current active library, optionally setting the selected - * unit and convert. + * Loads a symbol from the current active library, optionally setting the selected unit + * and convert. * * @param aAliasName The symbol alias name to load from the current library. * @param aUnit Unit to be selected @@ -366,8 +338,8 @@ private: * @param aConvert the initial DeMorgan variant to show. * @return True if a copy of \a aLibEntry was successfully copied. */ - bool LoadOneLibraryPartAux( LIB_ALIAS* aLibEntry, const wxString& aLibrary, - int aUnit, int aConvert ); + bool LoadOneLibraryPartAux( LIB_ALIAS* aLibEntry, const wxString& aLibrary, int aUnit, + int aConvert ); /** * Display the documentation of the selected component. diff --git a/eeschema/libedit/toolbars_libedit.cpp b/eeschema/libedit/toolbars_libedit.cpp index 312d9b696a..bf6428dd74 100644 --- a/eeschema/libedit/toolbars_libedit.cpp +++ b/eeschema/libedit/toolbars_libedit.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -110,24 +111,16 @@ void LIB_EDIT_FRAME::ReCreateHToolbar() m_mainToolBar->Add( EE_ACTIONS::showDeMorganAlternate, ACTION_TOOLBAR::TOGGLE ); KiScaledSeparator( m_mainToolBar, this ); - m_partSelectBox = new wxComboBox( m_mainToolBar, ID_LIBEDIT_SELECT_PART_NUMBER, wxEmptyString, + m_unitSelectBox = new wxComboBox( m_mainToolBar, ID_LIBEDIT_SELECT_PART_NUMBER, wxEmptyString, wxDefaultPosition, wxSize( LISTBOX_WIDTH, -1 ), 0, nullptr, wxCB_READONLY ); - m_mainToolBar->AddControl( m_partSelectBox ); + m_mainToolBar->AddControl( m_unitSelectBox ); KiScaledSeparator( m_mainToolBar, this ); - // JEY TODO: move to an action.... - m_mainToolBar->AddTool( ID_LIBEDIT_SYNC_PIN_EDIT, wxEmptyString, - KiScaledBitmap( pin2pin_xpm, this ), - _( "Synchronized pin edit mode\n" - "Propagates all changes (except pin numbers) to other units.\n" - "Enabled by default for multiunit parts with interchangeable units." ), - wxITEM_CHECK ); + m_mainToolBar->Add( EE_ACTIONS::toggleSyncedPinsMode, ACTION_TOOLBAR::TOGGLE ); KiScaledSeparator( m_mainToolBar, this ); - m_mainToolBar->AddTool( ID_ADD_PART_TO_SCHEMATIC, wxEmptyString, - KiScaledBitmap( export_xpm, this ), - _( "Add symbol to schematic" ) ); + m_mainToolBar->Add( EE_ACTIONS::addSymbolToSchematic ); // after adding the buttons to the toolbar, must call Realize() to reflect the changes m_mainToolBar->Realize(); @@ -173,10 +166,15 @@ void LIB_EDIT_FRAME::SyncToolbars() m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION ); m_mainToolBar->Toggle( EE_ACTIONS::showDatasheet, GetCurPart() != nullptr ); - m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganStandard, GetShowDeMorgan(), + m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganStandard, + GetShowDeMorgan(), m_convert == LIB_ITEM::LIB_CONVERT::BASE ); - m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganAlternate, GetShowDeMorgan(), + m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganAlternate, + GetShowDeMorgan(), m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN ); + m_mainToolBar->Toggle( EE_ACTIONS::toggleSyncedPinsMode, + GetCurPart() && GetCurPart()->IsMulti() && !GetCurPart()->UnitsLocked(), + m_SyncPinEdit ); m_mainToolBar->Refresh(); m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() ); diff --git a/eeschema/toolbars_viewlib.cpp b/eeschema/toolbars_viewlib.cpp index 1754199b6a..3e594ef5c6 100644 --- a/eeschema/toolbars_viewlib.cpp +++ b/eeschema/toolbars_viewlib.cpp @@ -76,9 +76,7 @@ void LIB_VIEW_FRAME::ReCreateHToolbar() m_mainToolBar->Add( EE_ACTIONS::showDatasheet ); KiScaledSeparator( m_mainToolBar, this ); - m_mainToolBar->AddTool( ID_ADD_PART_TO_SCHEMATIC, wxEmptyString, - KiScaledBitmap( export_xpm, this ), - _( "Add symbol to schematic" ) ); + m_mainToolBar->Add( EE_ACTIONS::addSymbolToSchematic ); // after adding the buttons to the toolbar, must call Realize() to reflect the changes m_mainToolBar->Realize(); diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index baab2dd415..f5a65ec4e0 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -158,6 +158,7 @@ public: static TOOL_ACTION exportNetlist; static TOOL_ACTION generateBOM; static TOOL_ACTION runSimulation; + static TOOL_ACTION addSymbolToSchematic; // Library management static TOOL_ACTION newSymbol; @@ -178,6 +179,7 @@ public: // Miscellaneous static TOOL_ACTION cleanupSheetPins; static TOOL_ACTION toggleHiddenPins; + static TOOL_ACTION toggleSyncedPinsMode; static TOOL_ACTION refreshPreview; static TOOL_ACTION restartMove; static TOOL_ACTION explicitCrossProbe; diff --git a/eeschema/tools/lib_control.cpp b/eeschema/tools/lib_control.cpp index 64f57c7cbc..81fb2baba8 100644 --- a/eeschema/tools/lib_control.cpp +++ b/eeschema/tools/lib_control.cpp @@ -22,6 +22,7 @@ */ #include +#include #include #include #include @@ -33,6 +34,7 @@ #include #include #include +#include TOOL_ACTION EE_ACTIONS::newSymbol( "eeschema.SymbolLibraryControl.newSymbol", AS_GLOBAL, 0, "", @@ -79,6 +81,11 @@ TOOL_ACTION EE_ACTIONS::exportSymbol( "eeschema.SymbolLibraryControl.exportSymbo _( "Export Symbol..." ), _( "Export a symbol to a new library file" ), export_part_xpm ); +TOOL_ACTION EE_ACTIONS::addSymbolToSchematic( "eeschema.SymbolLibraryControl.addSymbolToSchematic", + AS_GLOBAL, 0, "", + _( "Add Symbol to Schematic" ), _( "Add Symbol to Schematic" ), + export_xpm ); + TOOL_ACTION EE_ACTIONS::showElectricalTypes( "eeschema.SymbolLibraryControl.showElectricalTypes", AS_GLOBAL, 0, "", _( "Show Pin Electrical Types" ), _( "Annotate pins with their electrical types" ), @@ -99,6 +106,14 @@ TOOL_ACTION EE_ACTIONS::exportSymbolAsSVG( "eeschema.SymbolLibraryControl.export _( "Export Symbol as SVG..." ), _( "Create SVG file from the current symbol" ), plot_svg_xpm ); +TOOL_ACTION EE_ACTIONS::toggleSyncedPinsMode( "eeschema.SymbolLibraryControl.toggleSyncedPinsMode", + AS_GLOBAL, 0, "", + _( "Synchronized Pins Edit Mode" ), + _( "Synchronized Pins Edit Mode\n" + "When enabled propagates all changes (except pin numbers) to other units.\n" + "Enabled by default for multiunit parts with interchangeable units." ), + pin2pin_xpm ); + bool LIB_CONTROL::Init() { @@ -309,6 +324,18 @@ int LIB_CONTROL::ShowElectricalTypes( const TOOL_EVENT& aEvent ) } +int LIB_CONTROL::ToggleSyncedPinsMode( const TOOL_EVENT& aEvent ) +{ + if( !m_isLibEdit ) + return 0; + + LIB_EDIT_FRAME* editFrame = getEditFrame(); + editFrame->m_SyncPinEdit = !editFrame->m_SyncPinEdit; + + return 0; +} + + int LIB_CONTROL::ExportView( const TOOL_EVENT& aEvent ) { if( !m_isLibEdit ) @@ -394,6 +421,69 @@ int LIB_CONTROL::ExportSymbolAsSVG( const TOOL_EVENT& aEvent ) } +int LIB_CONTROL::AddSymbolToSchematic( const TOOL_EVENT& aEvent ) +{ + LIB_PART* part = nullptr; + LIB_ID libId; + int unit, convert; + + if( m_isLibEdit ) + { + LIB_EDIT_FRAME* editFrame = getEditFrame(); + + part = editFrame->GetCurPart(); + unit = editFrame->GetUnit(); + convert = editFrame->GetConvert(); + + if( part ) + libId = part->GetLibId(); + } + else + { + LIB_VIEW_FRAME* viewFrame = getEditFrame(); + + if( viewFrame->IsModal() ) + { + // if we're modal then we just need to return the symbol selection; the caller is + // already in a EE_ACTIONS::placeSymbol coroutine. + viewFrame->FinishModal(); + return 0; + } + else + { + part = viewFrame->GetSelectedSymbol(); + libId = viewFrame->GetSelectedAlias()->GetLibId(); + unit = viewFrame->GetUnit(); + convert = viewFrame->GetConvert(); + } + } + + if( part ) + { + SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH, false ); + + if( !schframe ) // happens when the schematic editor is not active (or closed) + { + DisplayErrorMessage( m_frame, _( "No schematic currently open." ) ); + return 0; + } + + SCH_COMPONENT* comp = new SCH_COMPONENT( *part, libId,g_CurrentSheet, unit, convert ); + + // Be sure the link to the corresponding LIB_PART is OK: + comp->Resolve( *m_frame->Prj().SchSymbolLibTable() ); + + if( schframe->GetAutoplaceFields() ) + comp->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false ); + + schframe->Raise(); + schframe->GetToolManager()->RunAction( EE_ACTIONS::placeSymbol, true, comp ); + } + + return 0; +} + + void LIB_CONTROL::setTransitions() { Go( &LIB_CONTROL::AddLibrary, ACTIONS::newLibrary.MakeEvent() ); @@ -416,10 +506,12 @@ void LIB_CONTROL::setTransitions() Go( &LIB_CONTROL::ExportSymbol, EE_ACTIONS::exportSymbol.MakeEvent() ); Go( &LIB_CONTROL::ExportView, EE_ACTIONS::exportSymbolView.MakeEvent() ); Go( &LIB_CONTROL::ExportSymbolAsSVG, EE_ACTIONS::exportSymbolAsSVG.MakeEvent() ); + Go( &LIB_CONTROL::AddSymbolToSchematic, EE_ACTIONS::addSymbolToSchematic.MakeEvent() ); Go( &LIB_CONTROL::OnDeMorgan, EE_ACTIONS::showDeMorganStandard.MakeEvent() ); Go( &LIB_CONTROL::OnDeMorgan, EE_ACTIONS::showDeMorganAlternate.MakeEvent() ); Go( &LIB_CONTROL::ShowElectricalTypes, EE_ACTIONS::showElectricalTypes.MakeEvent() ); Go( &LIB_CONTROL::ShowComponentTree, EE_ACTIONS::showComponentTree.MakeEvent() ); + Go( &LIB_CONTROL::ToggleSyncedPinsMode, EE_ACTIONS::toggleSyncedPinsMode.MakeEvent() ); } diff --git a/eeschema/tools/lib_control.h b/eeschema/tools/lib_control.h index 82a9e15ef1..1525b3a63e 100644 --- a/eeschema/tools/lib_control.h +++ b/eeschema/tools/lib_control.h @@ -59,11 +59,13 @@ public: int ExportSymbol( const TOOL_EVENT& aEvent ); int ExportView( const TOOL_EVENT& aEvent ); int ExportSymbolAsSVG( const TOOL_EVENT& aEvent ); + int AddSymbolToSchematic( const TOOL_EVENT& aEvent ); int OnDeMorgan( const TOOL_EVENT& aEvent ); int ShowElectricalTypes( const TOOL_EVENT& aEvent ); int ShowComponentTree( const TOOL_EVENT& aEvent ); + int ToggleSyncedPinsMode( const TOOL_EVENT& aEvent ); private: ///> Sets up handlers for various events. diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 5db687c9c0..6d44681d91 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -197,7 +197,10 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent ) // Prime the pump if( component ) + { + getViewControls()->WarpCursor( getViewControls()->GetMousePosition( false ) ); m_toolMgr->RunAction( EE_ACTIONS::refreshPreview ); + } else if( immediateMode ) m_toolMgr->RunAction( EE_ACTIONS::cursorClick ); diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 187009b6c2..2eaf2f3805 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -49,7 +49,6 @@ #include #include #include -#include #include // Save previous component library viewer state. @@ -70,10 +69,7 @@ BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME ) EVT_TOOL( ID_LIBVIEW_SELECT_PART, LIB_VIEW_FRAME::OnSelectSymbol ) EVT_TOOL( ID_LIBVIEW_NEXT, LIB_VIEW_FRAME::onSelectNextSymbol ) EVT_TOOL( ID_LIBVIEW_PREVIOUS, LIB_VIEW_FRAME::onSelectPreviousSymbol ) - EVT_TOOL_RANGE( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, - LIB_VIEW_FRAME::onSelectSymbolBodyStyle ) EVT_CHOICE( ID_LIBVIEW_SELECT_PART_NUMBER, LIB_VIEW_FRAME::onSelectSymbolUnit ) - EVT_TOOL( ID_ADD_PART_TO_SCHEMATIC, LIB_VIEW_FRAME::OnAddPartToSchematic ) // listbox events EVT_LISTBOX( ID_LIBVIEW_LIB_LIST, LIB_VIEW_FRAME::ClickOnLibList ) @@ -230,8 +226,7 @@ void LIB_VIEW_FRAME::setupTools() m_toolManager->RegisterTool( new ZOOM_TOOL ); m_toolManager->RegisterTool( new EE_INSPECTION_TOOL ); // manage show datasheet m_toolManager->RegisterTool( new EE_SELECTION_TOOL ); // manage context menu - m_toolManager->RegisterTool( new LIB_CONTROL ); // manage show electrical type option - m_toolManager->RegisterTool( new LIB_MOVE_TOOL ); + m_toolManager->RegisterTool( new LIB_CONTROL ); m_toolManager->InitTools(); @@ -639,7 +634,7 @@ void LIB_VIEW_FRAME::SetSelectedComponent( const wxString& aComponentName ) void LIB_VIEW_FRAME::DClickOnCmpList( wxCommandEvent& event ) { - OnAddPartToSchematic( event ); + m_toolManager->RunAction( EE_ACTIONS::addSymbolToSchematic, true ); } @@ -749,43 +744,13 @@ const BOX2I LIB_VIEW_FRAME::GetDocumentExtents() const } -void LIB_VIEW_FRAME::OnAddPartToSchematic( wxCommandEvent& aEvent ) +void LIB_VIEW_FRAME::FinishModal() { - if( IsModal() ) - { - // if we're modal then we just need to return the symbol selection; the caller is - // already in a EE_ACTIONS::placeSymbol coroutine. - if( m_cmpList->GetSelection() >= 0 ) - DismissModal( true, m_libraryName + ':' + m_cmpList->GetStringSelection() ); - else - DismissModal( false ); + if( m_cmpList->GetSelection() >= 0 ) + DismissModal( true, m_libraryName + ':' + m_cmpList->GetStringSelection() ); + else + DismissModal( false ); - Close( true ); - return; - } - - if( GetSelectedSymbol() ) - { - SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false ); - - if( schframe == NULL ) // happens when the schematic editor is not active (or closed) - { - DisplayErrorMessage( this, _("No schematic currently open." ) ); - return; - } - - SCH_COMPONENT* component = new SCH_COMPONENT( *GetSelectedSymbol(), - GetSelectedAlias()->GetLibId(), - g_CurrentSheet, m_unit, m_convert ); - - // Be sure the link to the corresponding LIB_PART is OK: - component->Resolve( *Prj().SchSymbolLibTable() ); - - if( schframe->GetAutoplaceFields() ) - component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false ); - - schframe->Raise(); - schframe->GetToolManager()->RunAction( EE_ACTIONS::placeSymbol, true, component ); - } + Close( true ); } diff --git a/eeschema/viewlib_frame.h b/eeschema/viewlib_frame.h index 6f69b36fa0..aa12b4edcc 100644 --- a/eeschema/viewlib_frame.h +++ b/eeschema/viewlib_frame.h @@ -65,6 +65,11 @@ public: */ bool ShowModal( wxString* aSymbol, wxWindow* aParent ) override; + /** + * Send the selected symbol back to the caller. + */ + void FinishModal(); + void OnSize( wxSizeEvent& event ) override; /** @@ -151,15 +156,11 @@ private: void DClickOnCmpList( wxCommandEvent& event ); - void onUpdateAltBodyStyleButton( wxUpdateUIEvent& aEvent ); - void onUpdateNormalBodyStyleButton( wxUpdateUIEvent& aEvent ); void onUpdateUnitChoice( wxUpdateUIEvent& aEvent ); void onSelectNextSymbol( wxCommandEvent& aEvent ); void onSelectPreviousSymbol( wxCommandEvent& aEvent ); - void onSelectSymbolBodyStyle( wxCommandEvent& aEvent ); void onSelectSymbolUnit( wxCommandEvent& aEvent ); - void OnAddPartToSchematic( wxCommandEvent& aEvent ); void updatePreviewSymbol(); diff --git a/eeschema/viewlibs.cpp b/eeschema/viewlibs.cpp index 9e0b49eb5e..efada8d1f9 100644 --- a/eeschema/viewlibs.cpp +++ b/eeschema/viewlibs.cpp @@ -111,17 +111,6 @@ void LIB_VIEW_FRAME::onSelectPreviousSymbol( wxCommandEvent& aEvent ) } -void LIB_VIEW_FRAME::onSelectSymbolBodyStyle( wxCommandEvent& aEvent ) -{ - if( aEvent.GetId() == ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT ) - m_convert = LIB_ITEM::LIB_CONVERT::DEMORGAN; - else - m_convert = LIB_ITEM::LIB_CONVERT::BASE; - - updatePreviewSymbol(); -} - - void LIB_VIEW_FRAME::onSelectSymbolUnit( wxCommandEvent& aEvent ) { int ii = m_unitChoice->GetSelection();