diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 7f3cfdc809..02a4c91156 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -220,7 +220,6 @@ set( EESCHEMA_SRCS sch_edit_frame.cpp selpart.cpp sheet.cpp - sheetlab.cpp symbol_lib_table.cpp symbol_tree_model_adapter.cpp symbol_tree_synchronizing_adapter.cpp diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index 8594623492..9c48adf528 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -143,6 +143,7 @@ enum id_eeschema_frm ID_POPUP_SCH_ADD_JUNCTION, ID_POPUP_SCH_ADD_LABEL, ID_POPUP_SCH_ADD_GLABEL, + ID_POPUP_SCH_ADD_HLABEL, ID_POPUP_END_RANGE, // Dynamically bound in AddMenusForBus() diff --git a/eeschema/help_common_strings.h b/eeschema/help_common_strings.h index 94ee4bd113..f7c28fa692 100644 --- a/eeschema/help_common_strings.h +++ b/eeschema/help_common_strings.h @@ -62,16 +62,15 @@ #define HELP_PLACE_NETLABEL _( "Place net label" ) #define HELP_PLACE_GLOBALLABEL \ - _(\ - "Place global label.\nWarning: inside global hierarchy , all global labels with same name are connected" ) + _( "Place global label.\nAll global labels with same name are connected throughout the sheet hierarchy" ) #define HELP_PLACE_HIER_LABEL \ - _( "Place a hierarchical label. Label will be seen as a hierarchical pin in the sheet" ) + _( "Place a hierarchical label.\nHierarchical labels are exposed to other sheets through sheet pins" ) #define HELP_PLACE_JUNCTION _( "Place junction" ) #define HELP_PLACE_SHEET _( "Create hierarchical sheet" ) -#define HELP_IMPORT_SHEETPIN _( \ - "Place hierarchical pin imported from the corresponding hierarchical label" ) -#define HELP_PLACE_SHEETPIN _( "Place hierarchical pin in sheet" ) +#define HELP_IMPORT_SHEETPIN \ + _( "Place hierarchical sheet pin corresponding to a hierarchical label in the sheet" ) +#define HELP_PLACE_SHEETPIN _( "Place hierarchical sheet pin" ) #define HELP_PLACE_GRAPHICLINES _( "Place graphic lines or polygons" ) #define HELP_PLACE_GRAPHICTEXTS _( "Place text" ) diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index 0a90275210..64c2a0ea23 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -47,7 +47,6 @@ #include #include -static void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame ); static void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame ); static void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet ); static void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, @@ -64,10 +63,6 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) { switch( GetToolId() ) { - case ID_WIRE_BUTT: - AddMenusForWire( PopMenu, NULL, this ); - break; - case ID_BUS_BUTT: AddMenusForBus( PopMenu, NULL, this ); break; @@ -86,10 +81,6 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) case SCH_LINE_T: switch( item->GetLayer() ) { - case LAYER_WIRE: - AddMenusForWire( PopMenu, (SCH_LINE*) item, this ); - break; - case LAYER_BUS: AddMenusForBus( PopMenu, (SCH_LINE*) item, this ); break; @@ -155,23 +146,6 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, SYMBOL_LIB } -void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame ) -{ - wxPoint pos = frame->GetCrossHairPosition(); - wxString msg; - - msg = AddHotkeyName( _( "Add Junction" ), g_Schematic_Hotkeys_Descr, HK_ADD_JUNCTION ); - AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_JUNCTION, msg, KiBitmap( add_junction_xpm ) ); - msg = AddHotkeyName( _( "Add Label..." ), g_Schematic_Hotkeys_Descr, HK_ADD_LABEL ); - AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_LABEL, msg, KiBitmap( add_line_label_xpm ) ); - - // Add global label command only if the cursor is over one end of the wire. - if( Wire->IsEndPoint( pos ) ) - AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add Global Label..." ), - KiBitmap( add_glabel_xpm ) ); -} - - void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame ) { SCH_SELECTION_TOOL* selTool = frame->GetToolManager()->GetTool(); @@ -195,17 +169,6 @@ void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame ) if( bus_unfold_menu ) PopMenu->AppendSubMenu( bus_unfold_menu, _( "Unfold Bus" ) ); - - PopMenu->AppendSeparator(); - msg = AddHotkeyName( _( "Add Junction" ), g_Schematic_Hotkeys_Descr, HK_ADD_JUNCTION ); - AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_JUNCTION, msg, KiBitmap( add_junction_xpm ) ); - msg = AddHotkeyName( _( "Add Label..." ), g_Schematic_Hotkeys_Descr, HK_ADD_LABEL ); - AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_LABEL, msg, KiBitmap( add_line_label_xpm ) ); - - // Add global label command only if the cursor is over one end of the bus. - if( Bus->IsEndPoint( pos ) ) - AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add Global Label..." ), - KiBitmap( add_glabel_xpm ) ); } diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index f3161be134..100b2efde9 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1172,7 +1172,7 @@ bool SCH_EDIT_FRAME::isAutoSaveRequired() const } -void SCH_EDIT_FRAME::AddItemToScreen( SCH_ITEM* aItem, bool aUndoAppend ) +void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_ITEM* aItem, bool aUndoAppend ) { SCH_SCREEN* screen = GetScreen(); diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index a37b980753..b069ba5abc 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -379,7 +379,7 @@ public: * Add an item to the schematic and adds the changes to the undo/redo container. * @param aUndoAppend True if the action should be appended to the current undo record. */ - void AddItemToScreen( SCH_ITEM* aItem, bool aUndoAppend = false ); + void AddItemToScreenAndUndoList( SCH_ITEM* aItem, bool aUndoAppend = false ); /** * Finds a component in the schematic and an item in this component. diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index e9fbbf1692..a5b1676439 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -28,14 +28,13 @@ #include #include #include - #include #include #include #include #include - #include +#include bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy, @@ -304,3 +303,103 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy, } +PINSHEETLABEL_SHAPE SCH_EDIT_FRAME::m_lastSheetPinType = NET_INPUT; +wxSize SCH_EDIT_FRAME::m_lastSheetPinTextSize( -1, -1 ); +wxPoint SCH_EDIT_FRAME::m_lastSheetPinPosition; + +const wxSize &SCH_EDIT_FRAME::GetLastSheetPinTextSize() +{ + // Delayed initialization (need the preferences to be loaded) + if( m_lastSheetPinTextSize.x == -1 ) + { + m_lastSheetPinTextSize.x = GetDefaultTextSize(); + m_lastSheetPinTextSize.y = GetDefaultTextSize(); + } + return m_lastSheetPinTextSize; +} + + +int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, bool aRedraw ) +{ + if( aSheetPin == NULL ) + return wxID_CANCEL; + + DIALOG_SCH_EDIT_SHEET_PIN dlg( this, aSheetPin ); + + if( dlg.ShowModal() == wxID_CANCEL ) + return wxID_CANCEL; + + if( aRedraw ) + RefreshItem( aSheetPin ); + + return wxID_OK; +} + + +SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet ) +{ + wxString line; + SCH_SHEET_PIN* sheetPin; + + sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), line ); + sheetPin->SetFlags( IS_NEW ); + sheetPin->SetTextSize( GetLastSheetPinTextSize() ); + sheetPin->SetShape( m_lastSheetPinType ); + + int response = EditSheetPin( sheetPin, false ); + + if( sheetPin->GetText().IsEmpty() || (response == wxID_CANCEL) ) + { + delete sheetPin; + return NULL; + } + + m_lastSheetPinType = sheetPin->GetShape(); + m_lastSheetPinTextSize = sheetPin->GetTextSize(); + + sheetPin->SetPosition( GetCrossHairPosition() ); + + return sheetPin; +} + + +SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet ) +{ + EDA_ITEM* item; + SCH_SHEET_PIN* sheetPin; + SCH_HIERLABEL* label = NULL; + + if( !aSheet->GetScreen() ) + return NULL; + + item = aSheet->GetScreen()->GetDrawItems(); + + for( ; item != NULL; item = item->Next() ) + { + if( item->Type() != SCH_HIER_LABEL_T ) + continue; + + label = (SCH_HIERLABEL*) item; + + /* A global label has been found: check if there a corresponding sheet label. */ + if( !aSheet->HasPin( label->GetText() ) ) + break; + + label = NULL; + } + + if( label == NULL ) + { + DisplayInfoMessage( this, _( "No new hierarchical labels found." ) ); + return NULL; + } + + sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), label->GetText() ); + sheetPin->SetFlags( IS_NEW ); + sheetPin->SetTextSize( GetLastSheetPinTextSize() ); + m_lastSheetPinType = label->GetShape(); + sheetPin->SetShape( label->GetShape() ); + sheetPin->SetPosition( GetCrossHairPosition() ); + + return sheetPin; +} diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp deleted file mode 100644 index 593167d7b8..0000000000 --- a/eeschema/sheetlab.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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) 2011 Wayne Stambaugh - * 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 - * 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 - */ - -/** - * @file sheetlab.cpp - * @brief Create and edit the SCH_SHEET_PIN items. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - - -PINSHEETLABEL_SHAPE SCH_EDIT_FRAME::m_lastSheetPinType = NET_INPUT; -wxSize SCH_EDIT_FRAME::m_lastSheetPinTextSize( -1, -1 ); -wxPoint SCH_EDIT_FRAME::m_lastSheetPinPosition; - -const wxSize &SCH_EDIT_FRAME::GetLastSheetPinTextSize() -{ - // Delayed initialization (need the preferences to be loaded) - if( m_lastSheetPinTextSize.x == -1 ) - { - m_lastSheetPinTextSize.x = GetDefaultTextSize(); - m_lastSheetPinTextSize.y = GetDefaultTextSize(); - } - return m_lastSheetPinTextSize; -} - - -int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, bool aRedraw ) -{ - if( aSheetPin == NULL ) - return wxID_CANCEL; - - DIALOG_SCH_EDIT_SHEET_PIN dlg( this, aSheetPin ); - - if( dlg.ShowModal() == wxID_CANCEL ) - return wxID_CANCEL; - - if( aRedraw ) - RefreshItem( aSheetPin ); - - return wxID_OK; -} - - -SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet ) -{ - wxString line; - SCH_SHEET_PIN* sheetPin; - - sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), line ); - sheetPin->SetFlags( IS_NEW ); - sheetPin->SetTextSize( GetLastSheetPinTextSize() ); - sheetPin->SetShape( m_lastSheetPinType ); - - int response = EditSheetPin( sheetPin, false ); - - if( sheetPin->GetText().IsEmpty() || (response == wxID_CANCEL) ) - { - delete sheetPin; - return NULL; - } - - m_lastSheetPinType = sheetPin->GetShape(); - m_lastSheetPinTextSize = sheetPin->GetTextSize(); - - sheetPin->SetPosition( GetCrossHairPosition() ); - - return sheetPin; -} - - -SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet ) -{ - EDA_ITEM* item; - SCH_SHEET_PIN* sheetPin; - SCH_HIERLABEL* label = NULL; - - if( !aSheet->GetScreen() ) - return NULL; - - item = aSheet->GetScreen()->GetDrawItems(); - - for( ; item != NULL; item = item->Next() ) - { - if( item->Type() != SCH_HIER_LABEL_T ) - continue; - - label = (SCH_HIERLABEL*) item; - - /* A global label has been found: check if there a corresponding sheet label. */ - if( !aSheet->HasPin( label->GetText() ) ) - break; - - label = NULL; - } - - if( label == NULL ) - { - DisplayInfoMessage( this, _( "No new hierarchical labels found." ) ); - return NULL; - } - - sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), label->GetText() ); - sheetPin->SetFlags( IS_NEW ); - sheetPin->SetTextSize( GetLastSheetPinTextSize() ); - m_lastSheetPinType = label->GetShape(); - sheetPin->SetShape( label->GetShape() ); - sheetPin->SetPosition( GetCrossHairPosition() ); - - return sheetPin; -} diff --git a/eeschema/tools/sch_actions.cpp b/eeschema/tools/sch_actions.cpp index 92fe32aa41..cdf93b3b0d 100644 --- a/eeschema/tools/sch_actions.cpp +++ b/eeschema/tools/sch_actions.cpp @@ -146,6 +146,9 @@ OPT SCH_ACTIONS::TranslateLegacyId( int aId ) case ID_GLOBALLABEL_BUTT: return SCH_ACTIONS::placeGlobalLabel.MakeEvent(); + case ID_POPUP_SCH_ADD_HLABEL: + return SCH_ACTIONS::addHierLabel.MakeEvent(); + case ID_MENU_HIERLABEL_BUTT: case ID_HIERLABEL_BUTT: return SCH_ACTIONS::placeHierarchicalLabel.MakeEvent(); diff --git a/eeschema/tools/sch_actions.h b/eeschema/tools/sch_actions.h index 3d5ca9970c..37c546643f 100644 --- a/eeschema/tools/sch_actions.h +++ b/eeschema/tools/sch_actions.h @@ -121,6 +121,7 @@ public: static TOOL_ACTION addJunction; static TOOL_ACTION addLabel; static TOOL_ACTION addGlobalLabel; + static TOOL_ACTION addHierLabel; static TOOL_ACTION toShapeSlash; static TOOL_ACTION toShapeBackslash; static TOOL_ACTION toLabel; diff --git a/eeschema/tools/sch_drawing_tool.cpp b/eeschema/tools/sch_drawing_tool.cpp index 3d32c85bc3..ea64f554f3 100644 --- a/eeschema/tools/sch_drawing_tool.cpp +++ b/eeschema/tools/sch_drawing_tool.cpp @@ -185,6 +185,10 @@ TOOL_ACTION SCH_ACTIONS::addGlobalLabel( "eeschema.InteractiveEditing.addGlobalL AS_GLOBAL, 0, _( "Add Global Label" ), _( "Add a global label to a wire or bus" ), add_glabel_xpm, AF_NONE ); +TOOL_ACTION SCH_ACTIONS::addHierLabel( "eeschema.InteractiveEditing.addHierLabel", + AS_GLOBAL, 0, _( "Add Hierarchical Label" ), _( "Add a hierarchical label to a wire or bus" ), + add_hierarchical_label_xpm, AF_NONE ); + SCH_DRAWING_TOOL::SCH_DRAWING_TOOL() : TOOL_INTERACTIVE( "eeschema.InteractiveDrawing" ), @@ -205,6 +209,8 @@ SCH_DRAWING_TOOL::~SCH_DRAWING_TOOL() bool SCH_DRAWING_TOOL::Init() { + static KICAD_T wireOrBusTypes[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT }; + m_frame = getEditFrame(); m_selectionTool = m_toolMgr->GetTool(); @@ -232,6 +238,11 @@ bool SCH_DRAWING_TOOL::Init() return ( aSel.Empty() || dynamic_cast( aSel.Front() )->GetEditFlags() == 0 ); }; + auto idleBusOrLineToolCondition = ( busToolCondition || lineToolCondition ) && idleCondition; + + auto wireOrBusSelectionCondition = SELECTION_CONDITIONS::MoreThan( 0 ) + && SELECTION_CONDITIONS::OnlyTypes( wireOrBusTypes ); + auto drawingSegmentsCondition = [] ( const SELECTION& aSel ) { return ( aSel.GetSize() >= 1 && dynamic_cast( aSel.Front() ) @@ -241,6 +252,10 @@ bool SCH_DRAWING_TOOL::Init() auto singleSheetCondition = SELECTION_CONDITIONS::Count( 1 ) && SELECTION_CONDITIONS::OnlyType( SCH_SHEET_T ); + auto belowRootSheetCondition = [] ( const SELECTION& aSel ) { + return g_CurrentSheet->Last() != g_RootSheet; + }; + auto& ctxMenu = m_menu.GetMenu(); // cancel current tool goes in main context menu at the top if present @@ -254,6 +269,12 @@ bool SCH_DRAWING_TOOL::Init() ctxMenu.AddItem( SCH_ACTIONS::finishLine, lineToolCondition && drawingSegmentsCondition, 1 ); ctxMenu.AddItem( SCH_ACTIONS::resizeSheet, sheetToolCondition && idleCondition, 1 ); + ctxMenu.AddSeparator( idleBusOrLineToolCondition, 100 ); + ctxMenu.AddItem( SCH_ACTIONS::addJunction, idleBusOrLineToolCondition, 100 ); + ctxMenu.AddItem( SCH_ACTIONS::addLabel, idleBusOrLineToolCondition, 100 ); + ctxMenu.AddItem( SCH_ACTIONS::addGlobalLabel, idleBusOrLineToolCondition, 100 ); + ctxMenu.AddItem( SCH_ACTIONS::addHierLabel, idleBusOrLineToolCondition, 100 ); + ctxMenu.AddSeparator( activeToolCondition, 1000 ); m_menu.AddStandardSubMenus( m_frame ); @@ -263,6 +284,11 @@ bool SCH_DRAWING_TOOL::Init() selToolMenu.AddItem( SCH_ACTIONS::resizeSheet, singleSheetCondition, 1 ); + selToolMenu.AddItem( SCH_ACTIONS::addJunction, wireOrBusSelectionCondition, 100 ); + selToolMenu.AddItem( SCH_ACTIONS::addLabel, wireOrBusSelectionCondition, 100 ); + selToolMenu.AddItem( SCH_ACTIONS::addGlobalLabel, wireOrBusSelectionCondition, 100 ); + selToolMenu.AddItem( SCH_ACTIONS::addHierLabel, wireOrBusSelectionCondition, 100 ); + return true; } @@ -299,6 +325,18 @@ int SCH_DRAWING_TOOL::AddGlobalLabel( const TOOL_EVENT& aEvent ) } +int SCH_DRAWING_TOOL::AddHierLabel( const TOOL_EVENT& aEvent ) +{ + return doAddItem( SCH_HIER_LABEL_T ); +} + + +int SCH_DRAWING_TOOL::ImportHierLable( const TOOL_EVENT& aEvent ) +{ + +} + + int SCH_DRAWING_TOOL::doAddItem( KICAD_T aType ) { m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true ); @@ -309,10 +347,13 @@ int SCH_DRAWING_TOOL::doAddItem( KICAD_T aType ) { case SCH_LABEL_T: item = m_frame->CreateNewText( LAYER_LOCLABEL ); break; case SCH_GLOBAL_LABEL_T: item = m_frame->CreateNewText( LAYER_GLOBLABEL ); break; + case SCH_HIER_LABEL_T: item = m_frame->CreateNewText( LAYER_HIERLABEL ); break; + case SCH_TEXT_T: item = m_frame->CreateNewText( LAYER_NOTES ); break; default: wxFAIL_MSG( "doAddItem(): unknown type" ); } - m_frame->AddItemToScreen( item ); + m_frame->AddItemToScreenAndUndoList( item ); + m_frame->SetNoToolSelected(); return 0; @@ -434,8 +475,7 @@ int SCH_DRAWING_TOOL::doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER { m_view->ClearPreview(); - // Will perform SaveCopyInUndoList(): - m_frame->AddItemToScreen( aComponent ); + m_frame->AddItemToScreenAndUndoList( aComponent ); aComponent = nullptr; } @@ -558,7 +598,7 @@ int SCH_DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent ) { m_view->ClearPreview(); - m_frame->AddItemToScreen( image ); + m_frame->AddItemToScreenAndUndoList( image ); image = nullptr; } @@ -662,8 +702,7 @@ int SCH_DRAWING_TOOL::doSingleClickPlace( KICAD_T aType ) if( item ) { item->SetFlags( IS_NEW ); - m_frame->AddItemToScreen( item ); - m_frame->SaveCopyInUndoList( item, UR_NEW ); + m_frame->AddItemToScreenAndUndoList( item ); m_frame->SetRepeatItem( item ); m_frame->GetScreen()->SetCurItem( item ); @@ -820,7 +859,7 @@ int SCH_DRAWING_TOOL::doTwoClickPlace( KICAD_T aType ) { m_view->ClearPreview(); - m_frame->AddItemToScreen( item ); + m_frame->AddItemToScreenAndUndoList( item ); item = nullptr; } @@ -1545,7 +1584,6 @@ int SCH_DRAWING_TOOL::doDrawSheet( SCH_SHEET *aSheet ) } else { - m_frame->AddItemToScreen( aSheet ); aSheet = nullptr; m_view->ClearPreview(); @@ -1556,7 +1594,7 @@ int SCH_DRAWING_TOOL::doDrawSheet( SCH_SHEET *aSheet ) { if( aSheet ) { - m_frame->AddItemToScreen( aSheet ); + m_frame->AddItemToScreenAndUndoList( aSheet ); aSheet = nullptr; m_view->ClearPreview(); @@ -1645,4 +1683,5 @@ void SCH_DRAWING_TOOL::setTransitions() Go( &SCH_DRAWING_TOOL::AddJunction, SCH_ACTIONS::addJunction.MakeEvent() ); Go( &SCH_DRAWING_TOOL::AddLabel, SCH_ACTIONS::addLabel.MakeEvent() ); Go( &SCH_DRAWING_TOOL::AddGlobalLabel, SCH_ACTIONS::addGlobalLabel.MakeEvent() ); + Go( &SCH_DRAWING_TOOL::AddHierLabel, SCH_ACTIONS::addHierLabel.MakeEvent() ); } diff --git a/eeschema/tools/sch_drawing_tool.h b/eeschema/tools/sch_drawing_tool.h index 03ee4eeabc..6c9f2a47cd 100644 --- a/eeschema/tools/sch_drawing_tool.h +++ b/eeschema/tools/sch_drawing_tool.h @@ -80,6 +80,8 @@ public: int AddJunction( const TOOL_EVENT& aEvent ); int AddLabel( const TOOL_EVENT& aEvent ); int AddGlobalLabel( const TOOL_EVENT& aEvent ); + int AddHierLabel( const TOOL_EVENT& aEvent ); + int ImportHierLable( const TOOL_EVENT& aEvent ); int PlaceSymbol( const TOOL_EVENT& aEvent ); int PlacePower( const TOOL_EVENT& aEvent ); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 5504e520c6..1957120c79 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -389,7 +389,6 @@ bool SCH_EDIT_TOOL::Init() selToolMenu.AddItem( SCH_ACTIONS::toHLabel, toHLabelCondition, 200 ); selToolMenu.AddItem( SCH_ACTIONS::toGLabel, toGLabelCondition, 200 ); selToolMenu.AddItem( SCH_ACTIONS::toText, toTextlCondition, 200 ); - selToolMenu.AddItem( SCH_ACTIONS::selectConnection, wireOrBusSelectionCondition, 200 ); selToolMenu.AddItem( SCH_ACTIONS::breakWire, wireSelectionCondition, 200 ); selToolMenu.AddItem( SCH_ACTIONS::breakBus, busSelectionCondition, 200 ); diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index a765d61651..8fa275624b 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -655,7 +655,7 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent ) } item->SetFlags( IS_NEW | IS_MOVED ); - m_frame->AddItemToScreen( item, i > 0 ); + m_frame->AddItemToScreenAndUndoList( item, i > 0 ); } if( hasSheetPasted ) diff --git a/eeschema/tools/sch_selection_tool.cpp b/eeschema/tools/sch_selection_tool.cpp index 0ed7947cd5..5351f31785 100644 --- a/eeschema/tools/sch_selection_tool.cpp +++ b/eeschema/tools/sch_selection_tool.cpp @@ -95,9 +95,18 @@ SCH_SELECTION_TOOL::~SCH_SELECTION_TOOL() bool SCH_SELECTION_TOOL::Init() { + static KICAD_T wireOrBusTypes[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT }; + m_frame = getEditFrame(); - m_menu.GetMenu().AddSeparator( SELECTION_CONDITIONS::ShowAlways, 1000 ); + auto wireOrBusSelectionCondition = SELECTION_CONDITIONS::MoreThan( 0 ) + && SELECTION_CONDITIONS::OnlyTypes( wireOrBusTypes ); + + auto& ctxMenu = m_menu.GetMenu(); + + ctxMenu.AddItem( SCH_ACTIONS::selectConnection, wireOrBusSelectionCondition, 200 ); + + ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways, 1000 ); m_menu.AddStandardSubMenus( m_frame ); return true;