diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp index bf76000a54..244bb8bf76 100644 --- a/common/legacy_gal/eda_draw_frame.cpp +++ b/common/legacy_gal/eda_draw_frame.cpp @@ -80,7 +80,6 @@ BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER ) EVT_MENU_OPEN( EDA_DRAW_FRAME::OnMenuOpen ) EVT_MENU_CLOSE( EDA_DRAW_FRAME::OnMenuOpen ) EVT_MENU_HIGHLIGHT_ALL( EDA_DRAW_FRAME::OnMenuOpen ) - EVT_MENU_RANGE( ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_USER, EDA_DRAW_FRAME::OnSelectGrid ) END_EVENT_TABLE() @@ -333,16 +332,6 @@ void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent ) } -void EDA_DRAW_FRAME::ReCreateAuxiliaryToolbar() -{ -} - - -void EDA_DRAW_FRAME::ReCreateMenuBar() -{ -} - - int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName ) { @@ -355,7 +344,7 @@ int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, } -void EDA_DRAW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData ) +void EDA_DRAW_FRAME::PrintPage( wxDC* aDC ) { wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") ); } @@ -725,13 +714,6 @@ wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition, } -void EDA_DRAW_FRAME::SetMousePosition( const wxPoint& aPosition ) -{ - BASE_SCREEN* screen = GetScreen(); // virtual call - screen->setMousePosition( aPosition ); -} - - wxPoint EDA_DRAW_FRAME::RefPos( bool useMouse ) const { BASE_SCREEN* screen = GetScreen(); // virtual call diff --git a/common/tool/action_toolbar.cpp b/common/tool/action_toolbar.cpp index c79279f537..d03b18c409 100644 --- a/common/tool/action_toolbar.cpp +++ b/common/tool/action_toolbar.cpp @@ -63,6 +63,15 @@ void ACTION_TOOLBAR::Toggle( const TOOL_ACTION& aAction, bool aState ) } +void ACTION_TOOLBAR::Toggle( const TOOL_ACTION& aAction, bool aEnabled, bool aChecked ) +{ + int toolId = aAction.GetId() + ACTION_ID; + + EnableTool( toolId, aEnabled ); + ToggleTool( toolId, aEnabled && aChecked ); +} + + void ACTION_TOOLBAR::onToolEvent( wxAuiToolBarEvent& aEvent ) { OPT_TOOL_EVENT evt; diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index 576faece39..425d41c347 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -122,13 +122,13 @@ enum id_eeschema_frm ID_LIBEDIT_SELECT_PART_NUMBER, /* Library editor vertical toolbar IDs. */ - ID_LIBEDIT_PIN_BUTT, - ID_LIBEDIT_BODY_LINE_BUTT, - ID_LIBEDIT_BODY_ARC_BUTT, - ID_LIBEDIT_BODY_CIRCLE_BUTT, - ID_LIBEDIT_BODY_RECT_BUTT, - ID_LIBEDIT_BODY_TEXT_BUTT, - ID_LIBEDIT_ANCHOR_ITEM_BUTT, + ID_SYMBOL_PIN_TOOL, + ID_SYMBOL_LINE_TOOL, + ID_SYMBOL_ARC_TOOL, + ID_SYMBOL_CIRCLE_TOOL, + ID_SYMBOL_RECT_TOOL, + ID_SYMBOL_TEXT_TOOL, + ID_SYMBOL_ANCHOR_TOOL, ID_LIBEDIT_IMPORT_BODY_BUTT, ID_LIBEDIT_EXPORT_BODY_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT, diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index 41aeec3a28..1b786fa72f 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -101,8 +101,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) // Main horizontal toolbar. EVT_TOOL( ID_TO_LIBVIEW, LIB_EDIT_FRAME::OnOpenLibraryViewer ) EVT_TOOL( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnCheckComponent ) - EVT_TOOL( ID_DE_MORGAN_NORMAL_BUTT, LIB_EDIT_FRAME::OnSelectBodyStyle ) - EVT_TOOL( ID_DE_MORGAN_CONVERT_BUTT, LIB_EDIT_FRAME::OnSelectBodyStyle ) EVT_TOOL( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::OnSyncPinEditClick ) EVT_TOOL( ID_ADD_PART_TO_SCHEMATIC, LIB_EDIT_FRAME::OnAddPartToSchematic ) @@ -124,14 +122,8 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) // Update user interface elements. EVT_UPDATE_UI( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnUpdateHavePart ) - EVT_UPDATE_UI( ID_LIBEDIT_SAVE_AS, LIB_EDIT_FRAME::OnUpdateHavePart ) - EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::OnUpdateSyncPinEdit ) EVT_UPDATE_UI( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnUpdatePartNumber ) - EVT_UPDATE_UI( ID_DE_MORGAN_NORMAL_BUTT, LIB_EDIT_FRAME::OnUpdateDeMorganNormal ) - EVT_UPDATE_UI( ID_DE_MORGAN_CONVERT_BUTT, LIB_EDIT_FRAME::OnUpdateDeMorganConvert ) - EVT_UPDATE_UI_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT, - LIB_EDIT_FRAME::OnUpdateEditingPart ) END_EVENT_TABLE() @@ -389,17 +381,6 @@ void LIB_EDIT_FRAME::OnUpdateHavePart( wxUpdateUIEvent& aEvent ) } -void LIB_EDIT_FRAME::OnUpdateEditingPart( wxUpdateUIEvent& aEvent ) -{ - LIB_PART* part = GetCurPart(); - - aEvent.Enable( part != NULL ); - - if( part && aEvent.GetEventObject() == m_drawToolBar ) - aEvent.Check( GetToolId() == aEvent.GetId() ); -} - - void LIB_EDIT_FRAME::OnUpdateSyncPinEdit( wxUpdateUIEvent& event ) { LIB_PART* part = GetCurPart(); @@ -421,24 +402,6 @@ void LIB_EDIT_FRAME::OnUpdatePartNumber( wxUpdateUIEvent& event ) } -void LIB_EDIT_FRAME::OnUpdateDeMorganNormal( wxUpdateUIEvent& event ) -{ - LIB_PART* part = GetCurPart(); - - event.Enable( GetShowDeMorgan() || ( part && part->HasConversion() ) ); - event.Check( m_convert <= 1 ); -} - - -void LIB_EDIT_FRAME::OnUpdateDeMorganConvert( wxUpdateUIEvent& event ) -{ - LIB_PART* part = GetCurPart(); - - event.Enable( GetShowDeMorgan() || ( part && part->HasConversion() ) ); - event.Check( m_convert > 1 ); -} - - void LIB_EDIT_FRAME::OnSelectUnit( wxCommandEvent& event ) { int i = event.GetSelection(); @@ -456,18 +419,6 @@ void LIB_EDIT_FRAME::OnSelectUnit( wxCommandEvent& event ) } -void LIB_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event ) -{ - m_toolManager->RunAction( ACTIONS::cancelInteractive, true ); - m_toolManager->RunAction( EE_ACTIONS::clearSelection, true ); - - m_convert = event.GetId() == ID_DE_MORGAN_NORMAL_BUTT ? 1 : 2; - - m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); - RebuildView(); -} - - void LIB_EDIT_FRAME::OnSyncPinEditClick( wxCommandEvent& event ) { m_SyncPinEdit = m_mainToolBar->GetToolToggled( ID_LIBEDIT_SYNC_PIN_EDIT ); diff --git a/eeschema/libedit/lib_edit_frame.h b/eeschema/libedit/lib_edit_frame.h index 5dab1d0f99..f2d78a7ede 100644 --- a/eeschema/libedit/lib_edit_frame.h +++ b/eeschema/libedit/lib_edit_frame.h @@ -287,14 +287,10 @@ public: void ClearSearchTreeSelection(); void OnCheckComponent( wxCommandEvent& event ); - void OnSelectBodyStyle( wxCommandEvent& event ); - void OnUpdateEditingPart( wxUpdateUIEvent& event ); void OnUpdateHavePart( wxUpdateUIEvent& aEvent ); void OnUpdateSyncPinEdit( wxUpdateUIEvent& event ); void OnUpdatePartNumber( wxUpdateUIEvent& event ); - void OnUpdateDeMorganNormal( wxUpdateUIEvent& event ); - void OnUpdateDeMorganConvert( wxUpdateUIEvent& event ); void UpdateAfterSymbolProperties( wxString* aOldName, wxArrayString* aOldAliases ); void RebuildSymbolUnitsList(); @@ -329,11 +325,13 @@ public: */ void OnModify() override; - int GetUnit() { return m_unit; } + int GetUnit() const { return m_unit; } + void SetUnit( int aUnit ) { m_unit = aUnit; } - int GetConvert() { return m_convert; } + int GetConvert() const { return m_convert; } + void SetConvert( int aConvert ) { m_convert = aConvert; } - bool GetShowDeMorgan() { return m_showDeMorgan; } + bool GetShowDeMorgan() const { return m_showDeMorgan; } void SetShowDeMorgan( bool show ) { m_showDeMorgan = show; } void ClearMsgPanel() override { DisplayCmpDoc(); } @@ -467,12 +465,8 @@ public: * Print a page * * @param aDC = wxDC given by the calling print function - * @param aPrintMask = not used here - * @param aPrintMirrorMode = not used here (Set when printing in mirror mode) - * @param aData = a pointer on an auxiliary data (not always used, NULL if not used) */ - virtual void PrintPage( wxDC* aDC, LSET aPrintMask, - bool aPrintMirrorMode, void* aData = NULL ) override; + void PrintPage( wxDC* aDC ) override; /** * Creates the SVG print file for the current edited component. diff --git a/eeschema/libedit/libedit.cpp b/eeschema/libedit/libedit.cpp index 1f92f431d5..99a9c0cc68 100644 --- a/eeschema/libedit/libedit.cpp +++ b/eeschema/libedit/libedit.cpp @@ -257,6 +257,8 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, const wxString& a m_toolManager->RunAction( "common.Control.zoomFitScreen", true ); updateTitle(); RebuildSymbolUnitsList(); + SetShowDeMorgan( GetCurPart()->HasConversion() ); + SyncMenusAndToolbars(); // Display the document information based on the entry selected just in // case the entry is an alias. @@ -525,6 +527,7 @@ void LIB_EDIT_FRAME::UpdateAfterSymbolProperties( wxString* aOldName, wxArrayStr m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, part->GetName() ) ); RebuildSymbolUnitsList(); + SetShowDeMorgan( part->HasConversion() ); updateTitle(); DisplayCmpDoc(); diff --git a/eeschema/libedit/libedit_plot_component.cpp b/eeschema/libedit/libedit_plot_component.cpp index 5afc7b562c..93b263b9a8 100644 --- a/eeschema/libedit/libedit_plot_component.cpp +++ b/eeschema/libedit/libedit_plot_component.cpp @@ -175,7 +175,7 @@ void LIB_EDIT_FRAME::SVG_PlotComponent( const wxString& aFullFileName ) } -void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData ) +void LIB_EDIT_FRAME::PrintPage( wxDC* aDC ) { LIB_PART* part = GetCurPart(); diff --git a/eeschema/libedit/toolbars_libedit.cpp b/eeschema/libedit/toolbars_libedit.cpp index 1dd30564ff..921b3c2280 100644 --- a/eeschema/libedit/toolbars_libedit.cpp +++ b/eeschema/libedit/toolbars_libedit.cpp @@ -114,13 +114,8 @@ void LIB_EDIT_FRAME::ReCreateHToolbar() _( "Check duplicate and off grid pins" ) ); KiScaledSeparator( m_mainToolBar, this ); - - m_mainToolBar->AddTool( ID_DE_MORGAN_NORMAL_BUTT, wxEmptyString, - KiScaledBitmap( morgan1_xpm, this ), - _( "Show as \"De Morgan\" normal symbol" ), wxITEM_CHECK ); - m_mainToolBar->AddTool( ID_DE_MORGAN_CONVERT_BUTT, wxEmptyString, - KiScaledBitmap( morgan2_xpm, this ), - _( "Show as \"De Morgan\" convert symbol" ), wxITEM_CHECK ); + m_mainToolBar->Add( EE_ACTIONS::showDeMorganStandard, ACTION_TOOLBAR::TOGGLE ); + 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, @@ -176,7 +171,10 @@ void LIB_EDIT_FRAME::SyncMenusAndToolbars() 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 ); - // JEY TODO: deMorgan buttons... + m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganStandard, GetShowDeMorgan(), + m_convert == LIB_ITEM::LIB_CONVERT::BASE ); + m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganAlternate, GetShowDeMorgan(), + m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN ); m_mainToolBar->Refresh(); m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() ); @@ -187,13 +185,13 @@ void LIB_EDIT_FRAME::SyncMenusAndToolbars() m_optionsToolBar->Toggle( EE_ACTIONS::showComponentTree, IsSearchTreeShown() ); m_optionsToolBar->Refresh(); - m_drawToolBar->Toggle( EE_ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED ); - m_drawToolBar->Toggle( EE_ACTIONS::placeSymbolPin, GetToolId() == ID_LIBEDIT_PIN_BUTT ); - m_drawToolBar->Toggle( EE_ACTIONS::placeSymbolText, GetToolId() == ID_LIBEDIT_BODY_TEXT_BUTT ); - m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolRectangle, GetToolId() == ID_LIBEDIT_BODY_RECT_BUTT ); - m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolCircle, GetToolId() == ID_LIBEDIT_BODY_CIRCLE_BUTT ); - m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolArc, GetToolId() == ID_LIBEDIT_BODY_ARC_BUTT ); - m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolLines, GetToolId() == ID_LIBEDIT_BODY_LINE_BUTT ); - m_drawToolBar->Toggle( EE_ACTIONS::placeSymbolAnchor, GetToolId() == ID_LIBEDIT_ANCHOR_ITEM_BUTT ); + m_drawToolBar->Toggle( EE_ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED ); + m_drawToolBar->Toggle( EE_ACTIONS::placeSymbolPin, GetToolId() == ID_SYMBOL_PIN_TOOL ); + m_drawToolBar->Toggle( EE_ACTIONS::placeSymbolText, GetToolId() == ID_SYMBOL_TEXT_TOOL ); + m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolRectangle, GetToolId() == ID_SYMBOL_RECT_TOOL ); + m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolCircle, GetToolId() == ID_SYMBOL_CIRCLE_TOOL ); + m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolArc, GetToolId() == ID_SYMBOL_ARC_TOOL ); + m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolLines, GetToolId() == ID_SYMBOL_LINE_TOOL ); + m_drawToolBar->Toggle( EE_ACTIONS::placeSymbolAnchor, GetToolId() == ID_SYMBOL_ANCHOR_TOOL ); m_drawToolBar->Refresh(); } diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index d6a38038ea..7b532aed43 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -994,7 +994,7 @@ void SCH_EDIT_FRAME::Print() } -void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData ) +void SCH_EDIT_FRAME::PrintPage( wxDC* aDC ) { wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() ); diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index ae2a57ee69..54c7e8b4c5 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -1062,12 +1062,8 @@ public: * Plot or print the current sheet to the clipboard. * * @param aDC = wxDC given by the calling print function - * @param aPrintMask = not used here - * @param aPrintMirrorMode = not used here (Set when printing in mirror mode) - * @param aData = a pointer on an auxiliary data (not always used, NULL if not used) */ - virtual void PrintPage( wxDC* aDC, LSET aPrintMask, - bool aPrintMirrorMode, void* aData = NULL ) override; + virtual void PrintPage( wxDC* aDC ) override; void SetSimulatorCommand( const wxString& aCommand ) { m_simulatorCommand = aCommand; } diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 245b50d015..a68a1b4e60 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -475,8 +475,7 @@ void SCH_EDIT_FRAME::DrawCurrentSheetToClipboard( wxCommandEvent& aEvt ) dc.SetUserScale( scale, scale ); dc.Clear(); - const LSET allLayersMask = LSET().set(); - PrintPage( &dc, allLayersMask, false ); + PrintPage( &dc ); screen->m_IsPrinting = false; if( wxTheClipboard->Open() ) diff --git a/eeschema/toolbars_viewlib.cpp b/eeschema/toolbars_viewlib.cpp index cdaf399ec5..d5f8a51871 100644 --- a/eeschema/toolbars_viewlib.cpp +++ b/eeschema/toolbars_viewlib.cpp @@ -68,20 +68,12 @@ void LIB_VIEW_FRAME::ReCreateHToolbar() toolbar->Add( ACTIONS::zoomFitScreen ); KiScaledSeparator( m_mainToolBar, this ); - m_mainToolBar->AddTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, wxEmptyString, - KiScaledBitmap( morgan1_xpm, this ), - _( "Show as \"De Morgan\" normal symbol" ), - wxITEM_CHECK ); - - m_mainToolBar->AddTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, wxEmptyString, - KiScaledBitmap( morgan2_xpm, this ), - _( "Show as \"De Morgan\" convert symbol" ), - wxITEM_CHECK ); + toolbar->Add( EE_ACTIONS::showDeMorganStandard, ACTION_TOOLBAR::TOGGLE ); + toolbar->Add( EE_ACTIONS::showDeMorganAlternate, ACTION_TOOLBAR::TOGGLE ); KiScaledSeparator( m_mainToolBar, this ); - - m_unitChoice = new wxChoice( m_mainToolBar, ID_LIBVIEW_SELECT_PART_NUMBER, wxDefaultPosition, - wxSize( 150, -1 ) ); + m_unitChoice = new wxChoice( m_mainToolBar, ID_LIBVIEW_SELECT_PART_NUMBER, + wxDefaultPosition, wxSize( 150, -1 ) ); m_mainToolBar->AddControl( m_unitChoice ); KiScaledSeparator( m_mainToolBar, this ); @@ -160,9 +152,13 @@ void LIB_VIEW_FRAME::ReCreateMenuBar() void LIB_VIEW_FRAME::SyncMenusAndToolbars() { + LIB_PART* symbol = GetSelectedSymbol(); LIB_ALIAS* alias = GetSelectedAlias(); m_mainToolBar->Toggle( EE_ACTIONS::showDatasheet, alias && !alias->GetDocFileName().IsEmpty() ); - // JEY TODO: deMorgan buttons... + m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganStandard, symbol && symbol->HasConversion(), + m_convert == LIB_FIELD::LIB_CONVERT::BASE ); + m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganAlternate, symbol && symbol->HasConversion(), + m_convert == LIB_FIELD::LIB_CONVERT::DEMORGAN ); m_mainToolBar->Refresh(); } diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index 571378d88c..89079b20b1 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -126,7 +126,9 @@ public: static TOOL_ACTION editValue; static TOOL_ACTION editFootprint; static TOOL_ACTION autoplaceFields; - static TOOL_ACTION convertDeMorgan; + static TOOL_ACTION toggleDeMorgan; + static TOOL_ACTION showDeMorganStandard; + static TOOL_ACTION showDeMorganAlternate; static TOOL_ACTION editSymbolUnit; static TOOL_ACTION addJunction; static TOOL_ACTION addLabel; diff --git a/eeschema/tools/ee_tool_base.h b/eeschema/tools/ee_tool_base.h index 901b77f4a5..e3b4efe0e8 100644 --- a/eeschema/tools/ee_tool_base.h +++ b/eeschema/tools/ee_tool_base.h @@ -70,7 +70,7 @@ public: { m_frame = getEditFrame(); m_selectionTool = m_toolMgr->GetTool(); - m_isLibEdit = dynamic_cast( m_frame ) != nullptr; + m_isLibEdit = m_frame->IsType( FRAME_SCH_LIB_EDITOR ); // A basic context manu. Many (but not all) tools will choose to override this. diff --git a/eeschema/tools/lib_control.cpp b/eeschema/tools/lib_control.cpp index 8f7a6c79b0..fb73384605 100644 --- a/eeschema/tools/lib_control.cpp +++ b/eeschema/tools/lib_control.cpp @@ -26,12 +26,13 @@ #include #include #include +#include #include TOOL_ACTION EE_ACTIONS::showElectricalTypes( "eeschema.SymbolLibraryControl.showElectricalTypes", AS_GLOBAL, 0, - _( "Show Pin Electrical Types" ), "", + _( "Show Pin Electrical Types" ), _( "Annotate pins with their electrical types" ), pin_show_etype_xpm ); @@ -43,28 +44,62 @@ TOOL_ACTION EE_ACTIONS::showComponentTree( "eeschema.SymbolLibraryControl.showCo int LIB_CONTROL::Save( const TOOL_EVENT& aEvent ) { - m_frame->OnSave(); + if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) ) + static_cast( m_frame )->OnSave(); + return 0; } int LIB_CONTROL::SaveAs( const TOOL_EVENT& aEvent ) { - m_frame->OnSaveAs(); + if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) ) + static_cast( m_frame )->OnSaveAs(); + return 0; } int LIB_CONTROL::SaveAll( const TOOL_EVENT& aEvent ) { - m_frame->OnSaveAll(); + if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) ) + static_cast( m_frame )->OnSaveAll(); + return 0; } int LIB_CONTROL::Revert( const TOOL_EVENT& aEvent ) { - m_frame->OnRevert(); + if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) ) + static_cast( m_frame )->OnRevert(); + + return 0; +} + + +int LIB_CONTROL::OnDeMorgan( const TOOL_EVENT& aEvent ) +{ + int convert = aEvent.IsAction( &EE_ACTIONS::showDeMorganStandard ) ? + LIB_ITEM::LIB_CONVERT::BASE : LIB_ITEM::LIB_CONVERT::DEMORGAN; + + if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) ) + { + m_toolMgr->RunAction( ACTIONS::cancelInteractive, true ); + m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); + + LIB_EDIT_FRAME* libEditFrame = static_cast( m_frame ); + libEditFrame->SetConvert( convert ); + + m_toolMgr->ResetTools( TOOL_BASE::MODEL_RELOAD ); + libEditFrame->RebuildView(); + } + else if( m_frame->IsType( FRAME_SCH_VIEWER ) || m_frame->IsType( FRAME_SCH_VIEWER_MODAL ) ) + { + LIB_VIEW_FRAME* libViewFrame = static_cast( m_frame ); + libViewFrame->SetUnitAndConvert( libViewFrame->GetUnit(), convert ); + } + return 0; } @@ -80,12 +115,10 @@ int LIB_CONTROL::ShowLibraryBrowser( const TOOL_EVENT& aEvent ) int LIB_CONTROL::ShowComponentTree( const TOOL_EVENT& aEvent ) { - if( m_isLibEdit ) + if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) ) { - LIB_EDIT_FRAME* editFrame = static_cast( m_frame ); - wxCommandEvent dummy; - editFrame->OnToggleSearchTree( dummy ); + static_cast( m_frame )->OnToggleSearchTree( dummy ); } return 0; @@ -112,6 +145,9 @@ void LIB_CONTROL::setTransitions() Go( &LIB_CONTROL::SaveAll, ACTIONS::saveAll.MakeEvent() ); Go( &LIB_CONTROL::Revert, ACTIONS::revert.MakeEvent() ); + Go( &LIB_CONTROL::OnDeMorgan, EE_ACTIONS::showDeMorganStandard.MakeEvent() ); + Go( &LIB_CONTROL::OnDeMorgan, EE_ACTIONS::showDeMorganAlternate.MakeEvent() ); + Go( &LIB_CONTROL::ShowLibraryBrowser, EE_ACTIONS::showLibraryBrowser.MakeEvent() ); Go( &LIB_CONTROL::ShowElectricalTypes, EE_ACTIONS::showElectricalTypes.MakeEvent() ); Go( &LIB_CONTROL::ShowComponentTree, EE_ACTIONS::showComponentTree.MakeEvent() ); diff --git a/eeschema/tools/lib_control.h b/eeschema/tools/lib_control.h index a503a4b926..2f104bfd33 100644 --- a/eeschema/tools/lib_control.h +++ b/eeschema/tools/lib_control.h @@ -35,11 +35,11 @@ class LIB_EDIT_FRAME; * * Handles actions for the various symbol editor and viewers. */ -class LIB_CONTROL : public wxEvtHandler, public EE_TOOL_BASE +class LIB_CONTROL : public wxEvtHandler, public EE_TOOL_BASE { public: LIB_CONTROL() : - EE_TOOL_BASE( "eeschema.SymbolLibraryControl" ) + EE_TOOL_BASE( "eeschema.SymbolLibraryControl" ) { } virtual ~LIB_CONTROL() { } @@ -49,6 +49,8 @@ public: int SaveAll( const TOOL_EVENT& aEvent ); int Revert( const TOOL_EVENT& aEvent ); + int OnDeMorgan( const TOOL_EVENT& aEvent ); + int ShowLibraryBrowser( const TOOL_EVENT& aEvent ); int ShowElectricalTypes( const TOOL_EVENT& aEvent ); int ShowComponentTree( const TOOL_EVENT& aEvent ); diff --git a/eeschema/tools/lib_drawing_tools.cpp b/eeschema/tools/lib_drawing_tools.cpp index 8555afdf0f..109064d6ba 100644 --- a/eeschema/tools/lib_drawing_tools.cpp +++ b/eeschema/tools/lib_drawing_tools.cpp @@ -118,14 +118,14 @@ bool LIB_DRAWING_TOOLS::Init() int LIB_DRAWING_TOOLS::PlacePin( const TOOL_EVENT& aEvent ) { - m_frame->SetToolID( ID_LIBEDIT_PIN_BUTT, wxCURSOR_PENCIL, _( "Add pin" ) ); + m_frame->SetToolID( ID_SYMBOL_PIN_TOOL, wxCURSOR_PENCIL, _( "Add pin" ) ); return doTwoClickPlace( LIB_PIN_T ); } int LIB_DRAWING_TOOLS::PlaceText( const TOOL_EVENT& aEvent ) { - m_frame->SetToolID( ID_LIBEDIT_BODY_TEXT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) ); + m_frame->SetToolID( ID_SYMBOL_TEXT_TOOL, wxCURSOR_PENCIL, _( "Add text" ) ); return doTwoClickPlace( LIB_TEXT_T ); } @@ -275,13 +275,13 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) m_toolMgr->DeactivateTool(); if( aEvent.IsAction( &EE_ACTIONS::drawSymbolArc ) ) - m_frame->SetToolID( ID_LIBEDIT_BODY_ARC_BUTT, wxCURSOR_PENCIL, _( "Draw Arc" ) ); + m_frame->SetToolID( ID_SYMBOL_ARC_TOOL, wxCURSOR_PENCIL, _( "Draw Arc" ) ); else if( aEvent.IsAction( &EE_ACTIONS::drawSymbolCircle ) ) - m_frame->SetToolID( ID_LIBEDIT_BODY_CIRCLE_BUTT, wxCURSOR_PENCIL, _( "Draw Circle" ) ); + m_frame->SetToolID( ID_SYMBOL_CIRCLE_TOOL, wxCURSOR_PENCIL, _( "Draw Circle" ) ); else if( aEvent.IsAction( &EE_ACTIONS::drawSymbolLines ) ) - m_frame->SetToolID( ID_LIBEDIT_BODY_LINE_BUTT, wxCURSOR_PENCIL, _( "Draw Lines" ) ); + m_frame->SetToolID( ID_SYMBOL_LINE_TOOL, wxCURSOR_PENCIL, _( "Draw Lines" ) ); else if( aEvent.IsAction( &EE_ACTIONS::drawSymbolRectangle ) ) - m_frame->SetToolID( ID_LIBEDIT_BODY_RECT_BUTT, wxCURSOR_PENCIL, _( "Draw Rectangle" ) ); + m_frame->SetToolID( ID_SYMBOL_RECT_TOOL, wxCURSOR_PENCIL, _( "Draw Rectangle" ) ); else wxCHECK_MSG( false, 0, "Unknown action in LIB_DRAWING_TOOLS::DrawShape()" ); @@ -324,10 +324,10 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) switch( m_frame->GetToolId() ) { - case ID_LIBEDIT_BODY_ARC_BUTT: item = new LIB_ARC( part ); break; - case ID_LIBEDIT_BODY_CIRCLE_BUTT: item = new LIB_CIRCLE( part ); break; - case ID_LIBEDIT_BODY_LINE_BUTT: item = new LIB_POLYLINE( part ); break; - case ID_LIBEDIT_BODY_RECT_BUTT: item = new LIB_RECTANGLE( part ); break; + case ID_SYMBOL_ARC_TOOL: item = new LIB_ARC( part ); break; + case ID_SYMBOL_CIRCLE_TOOL: item = new LIB_CIRCLE( part ); break; + case ID_SYMBOL_LINE_TOOL: item = new LIB_POLYLINE( part ); break; + case ID_SYMBOL_RECT_TOOL: item = new LIB_RECTANGLE( part ); break; } item->SetWidth( LIB_EDIT_FRAME::g_LastLineWidth ); @@ -400,7 +400,7 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent ) { - m_frame->SetToolID( ID_LIBEDIT_ANCHOR_ITEM_BUTT, wxCURSOR_PENCIL, _( "Move symbol anchor" ) ); + m_frame->SetToolID( ID_SYMBOL_ANCHOR_TOOL, wxCURSOR_PENCIL, _( "Move symbol anchor" ) ); getViewControls()->ShowCursor( true ); getViewControls()->SetSnapping( true ); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 308c4765b1..d298d783b8 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -99,11 +99,21 @@ TOOL_ACTION EE_ACTIONS::autoplaceFields( "eeschema.InteractiveEdit.autoplaceFiel _( "Autoplace Fields" ), _( "Runs the automatic placement algorithm on the symbol's fields" ), autoplace_fields_xpm ); -TOOL_ACTION EE_ACTIONS::convertDeMorgan( "eeschema.InteractiveEdit.convertDeMorgan", +TOOL_ACTION EE_ACTIONS::toggleDeMorgan( "eeschema.InteractiveEdit.toggleDeMorgan", AS_GLOBAL, 0, _( "DeMorgan Conversion" ), _( "Switch between DeMorgan representations" ), morgan2_xpm ); +TOOL_ACTION EE_ACTIONS::showDeMorganStandard( "eeschema.InteractiveEdit.showDeMorganStandard", + AS_GLOBAL, 0, + _( "DeMorgan Standard" ), _( "Switch to standard DeMorgan representation" ), + morgan1_xpm ); + +TOOL_ACTION EE_ACTIONS::showDeMorganAlternate( "eeschema.InteractiveEdit.showDeMorganAlternate", + AS_GLOBAL, 0, + _( "DeMorgan Alternate" ), _( "Switch to alternate DeMorgan representation" ), + morgan2_xpm ); + TOOL_ACTION EE_ACTIONS::toShapeSlash( "eeschema.InteractiveEdit.toShapeSlash", AS_GLOBAL, 0, _( "Set Bus Entry Shape /" ), _( "Change the bus entry shape to /" ), @@ -347,7 +357,7 @@ bool SCH_EDIT_TOOL::Init() moveMenu.AddItem( EE_ACTIONS::editReference, singleComponentCondition ); moveMenu.AddItem( EE_ACTIONS::editValue, singleComponentCondition ); moveMenu.AddItem( EE_ACTIONS::editFootprint, singleComponentCondition ); - moveMenu.AddItem( EE_ACTIONS::convertDeMorgan, E_C::SingleDeMorganSymbol ); + moveMenu.AddItem( EE_ACTIONS::toggleDeMorgan, E_C::SingleDeMorganSymbol ); std::shared_ptr symUnitMenu = std::make_shared(); symUnitMenu->SetTool( this ); @@ -375,7 +385,7 @@ bool SCH_EDIT_TOOL::Init() drawMenu.AddItem( EE_ACTIONS::editValue, singleComponentCondition, 200 ); drawMenu.AddItem( EE_ACTIONS::editFootprint, singleComponentCondition, 200 ); drawMenu.AddItem( EE_ACTIONS::autoplaceFields, singleComponentCondition, 200 ); - drawMenu.AddItem( EE_ACTIONS::convertDeMorgan, E_C::SingleDeMorganSymbol, 200 ); + drawMenu.AddItem( EE_ACTIONS::toggleDeMorgan, E_C::SingleDeMorganSymbol, 200 ); std::shared_ptr symUnitMenu2 = std::make_shared(); symUnitMenu2->SetTool( drawingTools ); @@ -408,7 +418,7 @@ bool SCH_EDIT_TOOL::Init() selToolMenu.AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol, 200 ); selToolMenu.AddItem( EE_ACTIONS::editFootprint, E_C::SingleSymbol, 200 ); selToolMenu.AddItem( EE_ACTIONS::autoplaceFields, singleComponentCondition, 200 ); - selToolMenu.AddItem( EE_ACTIONS::convertDeMorgan, E_C::SingleSymbol, 200 ); + selToolMenu.AddItem( EE_ACTIONS::toggleDeMorgan, E_C::SingleSymbol, 200 ); std::shared_ptr symUnitMenu3 = std::make_shared(); symUnitMenu3->SetTool( m_selectionTool ); @@ -1123,13 +1133,22 @@ int SCH_EDIT_TOOL::ConvertDeMorgan( const TOOL_EVENT& aEvent ) SCH_COMPONENT* component = (SCH_COMPONENT*) selection.Front(); - if( component->IsNew() ) - m_toolMgr->RunAction( EE_ACTIONS::refreshPreview ); - else + if( aEvent.IsAction( &EE_ACTIONS::showDeMorganStandard ) + && component->GetConvert() == LIB_ITEM::LIB_CONVERT::BASE ) + return 0; + + if( aEvent.IsAction( &EE_ACTIONS::showDeMorganAlternate ) + && component->GetConvert() != LIB_ITEM::LIB_CONVERT::DEMORGAN ) + return 0; + + if( !component->IsNew() ) m_frame->SaveCopyInUndoList( component, UR_CHANGED ); m_frame->ConvertPart( component ); + if( component->IsNew() ) + m_toolMgr->RunAction( EE_ACTIONS::refreshPreview ); + return 0; } @@ -1350,7 +1369,9 @@ void SCH_EDIT_TOOL::setTransitions() Go( &SCH_EDIT_TOOL::EditField, EE_ACTIONS::editValue.MakeEvent() ); Go( &SCH_EDIT_TOOL::EditField, EE_ACTIONS::editFootprint.MakeEvent() ); Go( &SCH_EDIT_TOOL::AutoplaceFields, EE_ACTIONS::autoplaceFields.MakeEvent() ); - Go( &SCH_EDIT_TOOL::ConvertDeMorgan, EE_ACTIONS::convertDeMorgan.MakeEvent() ); + Go( &SCH_EDIT_TOOL::ConvertDeMorgan, EE_ACTIONS::toggleDeMorgan.MakeEvent() ); + Go( &SCH_EDIT_TOOL::ConvertDeMorgan, EE_ACTIONS::showDeMorganStandard.MakeEvent() ); + Go( &SCH_EDIT_TOOL::ConvertDeMorgan, EE_ACTIONS::showDeMorganAlternate.MakeEvent() ); Go( &SCH_EDIT_TOOL::ChangeShape, EE_ACTIONS::toShapeSlash.MakeEvent() ); Go( &SCH_EDIT_TOOL::ChangeShape, EE_ACTIONS::toShapeBackslash.MakeEvent() ); diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 39a1a538f5..f93877d0ac 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -86,8 +86,6 @@ BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME ) EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings ) EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, LIB_VIEW_FRAME::OnDisplayHotkeyList ) - EVT_UPDATE_UI( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, LIB_VIEW_FRAME::onUpdateNormalBodyStyleButton ) - EVT_UPDATE_UI( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, LIB_VIEW_FRAME::onUpdateAltBodyStyleButton ) EVT_UPDATE_UI( ID_LIBVIEW_SELECT_PART_NUMBER, LIB_VIEW_FRAME::onUpdateUnitChoice ) END_EVENT_TABLE() @@ -254,11 +252,7 @@ void LIB_VIEW_FRAME::SetUnitAndConvert( int aUnit, int aConvert ) m_convert = aConvert > 0 ? aConvert : LIB_ITEM::LIB_CONVERT::BASE; m_selection_changed = false; - // Update canvas - GetRenderSettings()->m_ShowUnit = m_unit; - GetRenderSettings()->m_ShowConvert = m_convert; - GetCanvas()->GetView()->MarkDirty(); - GetCanvas()->Refresh(); + updatePreviewSymbol(); } @@ -315,32 +309,6 @@ void LIB_VIEW_FRAME::updatePreviewSymbol() } -void LIB_VIEW_FRAME::onUpdateAltBodyStyleButton( wxUpdateUIEvent& aEvent ) -{ - LIB_PART* symbol = GetSelectedSymbol(); - - aEvent.Enable( symbol && symbol->HasConversion() ); - - if( symbol ) - aEvent.Check( m_convert > 1 ); - else - aEvent.Check( false ); -} - - -void LIB_VIEW_FRAME::onUpdateNormalBodyStyleButton( wxUpdateUIEvent& aEvent ) -{ - LIB_PART* symbol = GetSelectedSymbol(); - - aEvent.Enable( symbol && symbol->HasConversion() ); - - if( symbol ) - aEvent.Check( m_convert <= 1 ); - else - aEvent.Check( true ); -} - - bool LIB_VIEW_FRAME::ShowModal( wxString* aSymbol, wxWindow* aParent ) { if( aSymbol && !aSymbol->IsEmpty() ) diff --git a/include/draw_frame.h b/include/draw_frame.h index 9a66c70e2b..431c0d1d63 100644 --- a/include/draw_frame.h +++ b/include/draw_frame.h @@ -329,8 +329,6 @@ public: */ wxPoint GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize = NULL ) const; - void SetMousePosition( const wxPoint& aPosition ); - /** * Return the reference position, coming from either the mouse position * or the cursor position. @@ -423,10 +421,10 @@ public: void EraseMsgBox(); + void ReCreateMenuBar() override { } virtual void ReCreateHToolbar() = 0; virtual void ReCreateVToolbar() = 0; - virtual void ReCreateMenuBar() override; - virtual void ReCreateAuxiliaryToolbar(); + virtual void ReCreateAuxiliaryToolbar() { } // Toolbar accessors ACTION_TOOLBAR* GetMainToolBar() const { return m_mainToolBar; } @@ -677,11 +675,8 @@ public: * Print the page pointed by current screen, set by the calling print function. * * @param aDC = wxDC given by the calling print function - * @param aPrintMask = not used here - * @param aPrintMirrorMode = not used here (Set when printing in mirror mode) - * @param aData = a pointer on an auxiliary data (not always used, NULL if not used) */ - virtual void PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData = NULL ); + virtual void PrintPage( wxDC* aDC ); /** * Returns the canvas type stored in the application settings. diff --git a/include/tool/action_toolbar.h b/include/tool/action_toolbar.h index 533763010c..6462068f82 100644 --- a/include/tool/action_toolbar.h +++ b/include/tool/action_toolbar.h @@ -53,8 +53,14 @@ public: */ void Add( const TOOL_ACTION& aAction, bool aIsToggleEntry = false ); + /** + * Applies the default toggle action. For checked items this is check/uncheck; for + * non-checked items it's enable/disable. + */ void Toggle( const TOOL_ACTION& aAction, bool aState ); + void Toggle( const TOOL_ACTION& aAction, bool aEnabled, bool aChecked ); + static const bool TOGGLE = true; protected: diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 5c6e45eb04..3e5fc530d8 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -578,7 +578,7 @@ void PL_EDITOR_FRAME::UpdateStatusBar() } -void PL_EDITOR_FRAME::PrintPage( wxDC* aDC, LSET , bool , void * ) +void PL_EDITOR_FRAME::PrintPage( wxDC* aDC ) { GetScreen()->m_ScreenNumber = GetPageNumberOption() ? 1 : 2; PrintWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, wxEmptyString ); diff --git a/pagelayout_editor/pl_editor_frame.h b/pagelayout_editor/pl_editor_frame.h index f0a2aa40cb..f5a413d5e4 100644 --- a/pagelayout_editor/pl_editor_frame.h +++ b/pagelayout_editor/pl_editor_frame.h @@ -226,12 +226,8 @@ public: /** Virtual function PrintPage * used to print a page * @param aDC = wxDC given by the calling print function - * @param aPrintMasklayer = a 32 bits mask: bit n = 1 -> layer n is printed - * @param aPrintMirrorMode = not used here (Set when printing in mirror mode) - * @param aData = a pointer on an auxiliary data (not always used, NULL if not used) */ - virtual void PrintPage( wxDC* aDC, LSET aPrintMasklayer, bool aPrintMirrorMode, - void * aData ) override; + virtual void PrintPage( wxDC* aDC ) override; void OnFileHistory( wxCommandEvent& event );