Replace deleteNode and deleteConnection with selectNode and selectConnection.
This commit is contained in:
parent
1ff7869ec3
commit
423d430b58
|
@ -148,22 +148,14 @@ SEARCH_RESULT EDA_ITEM::IterateForward( EDA_ITEM* listStart,
|
|||
// many classes inherit this method, be careful:
|
||||
SEARCH_RESULT EDA_ITEM::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
|
||||
{
|
||||
KICAD_T stype;
|
||||
|
||||
#if 0 && defined(DEBUG)
|
||||
std::cout << GetClass().mb_str() << ' ';
|
||||
#endif
|
||||
|
||||
for( const KICAD_T* p = scanTypes; (stype = *p) != EOT; ++p )
|
||||
if( IsType( scanTypes ) )
|
||||
{
|
||||
// If caller wants to inspect my type
|
||||
if( stype == Type() )
|
||||
{
|
||||
if( SEARCH_QUIT == inspector( this, testData ) )
|
||||
return SEARCH_QUIT;
|
||||
|
||||
break;
|
||||
}
|
||||
if( SEARCH_QUIT == inspector( this, testData ) )
|
||||
return SEARCH_QUIT;
|
||||
}
|
||||
|
||||
return SEARCH_CONTINUE;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <tool/selection_conditions.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
|
||||
|
@ -48,15 +49,9 @@ SELECTION_CONDITION SELECTION_CONDITIONS::OnlyType( KICAD_T aType )
|
|||
}
|
||||
|
||||
|
||||
SELECTION_CONDITION SELECTION_CONDITIONS::OnlyTypes( const std::vector<KICAD_T>& aTypes )
|
||||
{
|
||||
return std::bind( &SELECTION_CONDITIONS::onlyTypesFunc, _1, aTypes );
|
||||
}
|
||||
|
||||
|
||||
SELECTION_CONDITION SELECTION_CONDITIONS::OnlyTypes( const KICAD_T aTypes[] )
|
||||
{
|
||||
return std::bind( &SELECTION_CONDITIONS::onlyTypesFuncArr, _1, aTypes );
|
||||
return std::bind( &SELECTION_CONDITIONS::onlyTypesFunc, _1, aTypes );
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,9 +90,11 @@ bool SELECTION_CONDITIONS::onlyTypeFunc( const SELECTION& aSelection, KICAD_T aT
|
|||
if( aSelection.Empty() )
|
||||
return false;
|
||||
|
||||
KICAD_T types[] = { aType, EOT };
|
||||
|
||||
for( const auto& item : aSelection )
|
||||
{
|
||||
if( item->Type() != aType )
|
||||
if( !item->IsType( types ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -105,54 +102,14 @@ bool SELECTION_CONDITIONS::onlyTypeFunc( const SELECTION& aSelection, KICAD_T aT
|
|||
}
|
||||
|
||||
|
||||
bool SELECTION_CONDITIONS::onlyTypesFunc( const SELECTION& aSelection, const std::vector<KICAD_T>& aTypes )
|
||||
bool SELECTION_CONDITIONS::onlyTypesFunc( const SELECTION& aSelection, const KICAD_T aTypes[] )
|
||||
{
|
||||
if( aSelection.Empty() )
|
||||
return false;
|
||||
|
||||
for( const auto& item : aSelection )
|
||||
{
|
||||
bool valid = false;
|
||||
|
||||
for( std::vector<KICAD_T>::const_iterator it = aTypes.begin(); it != aTypes.end(); ++it )
|
||||
{
|
||||
if( item->Type() == *it )
|
||||
{
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !valid )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool SELECTION_CONDITIONS::onlyTypesFuncArr( const SELECTION& aSelection, const KICAD_T aTypes[] )
|
||||
{
|
||||
if( aSelection.Empty() )
|
||||
return false;
|
||||
|
||||
for( const auto& item : aSelection )
|
||||
{
|
||||
bool valid = false;
|
||||
const KICAD_T* type = aTypes;
|
||||
|
||||
while( *type != EOT )
|
||||
{
|
||||
if( item->Type() == *type )
|
||||
{
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
|
||||
++type;
|
||||
}
|
||||
|
||||
if( !valid )
|
||||
if( !item->IsType( aTypes ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* aText, KICAD_T aType )
|
|||
newtext->SetIsDangling( aText->IsDangling() );
|
||||
|
||||
if( selected )
|
||||
m_toolManager->RunAction( SCH_ACTIONS::unselectItem, true, aText );
|
||||
m_toolManager->RunAction( SCH_ACTIONS::removeItemFromSel, true, aText );
|
||||
|
||||
if( !aText->IsNew() )
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* aText, KICAD_T aType )
|
|||
}
|
||||
|
||||
if( selected )
|
||||
m_toolManager->RunAction( SCH_ACTIONS::selectItem, true, newtext );
|
||||
m_toolManager->RunAction( SCH_ACTIONS::addItemToSel, true, newtext );
|
||||
|
||||
// if the old item is the current schematic item, replace it by the new text:
|
||||
if( screen->GetCurItem() == aText )
|
||||
|
|
|
@ -133,18 +133,10 @@ enum id_eeschema_frm
|
|||
ID_POPUP_SCH_BEGIN_WIRE,
|
||||
ID_POPUP_SCH_BEGIN_BUS,
|
||||
ID_POPUP_SCH_BEGIN_LINES,
|
||||
ID_POPUP_SCH_DELETE_CONNECTION,
|
||||
ID_POPUP_SCH_DELETE_NODE,
|
||||
|
||||
ID_POPUP_SCH_INIT_CMP,
|
||||
|
||||
ID_POPUP_SCH_RESIZE_SHEET,
|
||||
ID_POPUP_SCH_CLEANUP_SHEET,
|
||||
ID_POPUP_IMPORT_HLABEL_TO_SHEETPIN,
|
||||
ID_POPUP_SCH_GENERIC_ORIENT_CMP,
|
||||
ID_POPUP_SCH_GENERIC_EDIT_CMP,
|
||||
ID_POPUP_SCH_EDIT_CONVERT_CMP,
|
||||
ID_POPUP_SCH_EDIT_FIELD,
|
||||
ID_POPUP_SCH_ENTER_SHEET,
|
||||
ID_POPUP_SCH_LEAVE_SHEET,
|
||||
ID_POPUP_SCH_SELECT_ON_PCB,
|
||||
|
@ -194,6 +186,8 @@ enum id_eeschema_frm
|
|||
// events (menus, toolbar, context menu, etc.) that result in the same event handler.
|
||||
ID_CANCEL_CURRENT_COMMAND,
|
||||
|
||||
ID_HOTKEY_SELECT_NODE,
|
||||
ID_HOTKEY_SELECT_CONNECTION,
|
||||
ID_HOTKEY_HIGHLIGHT,
|
||||
ID_HIGHLIGHT_NET,
|
||||
ID_ADD_PART_TO_SCHEMATIC,
|
||||
|
|
|
@ -172,7 +172,7 @@ static EDA_HOTKEY HkEditComponentWithLibedit( _HKI( "Edit with Symbol Editor" ),
|
|||
HK_EDIT_COMPONENT_WITH_LIBEDIT, 'E' + GR_KB_CTRL,
|
||||
ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP );
|
||||
|
||||
static EDA_HOTKEY HkMove( _HKI( "Move Schematic Item" ), HK_MOVE_COMPONENT_OR_ITEM, 'M',
|
||||
static EDA_HOTKEY HkMove( _HKI( "Move Schematic Item" ), HK_MOVE, 'M',
|
||||
ID_SCH_MOVE );
|
||||
|
||||
static EDA_HOTKEY HkDuplicateItem( _HKI( "Duplicate" ), HK_DUPLICATE, 'D' + GR_KB_CTRL,
|
||||
|
@ -183,8 +183,6 @@ static EDA_HOTKEY HkMove2Drag( _HKI( "Move Block -> Drag Block" ),
|
|||
HK_MOVEBLOCK_TO_DRAGBLOCK, '\t', ID_POPUP_DRAG_BLOCK );
|
||||
static EDA_HOTKEY HkInsert( _HKI( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSERT );
|
||||
static EDA_HOTKEY HkDelete( _HKI( "Delete Item" ), HK_DELETE, WXK_DELETE );
|
||||
static EDA_HOTKEY HkDeleteNode( _HKI( "Delete Node" ), HK_DELETE_NODE, WXK_BACK,
|
||||
ID_POPUP_SCH_DELETE_NODE );
|
||||
|
||||
static EDA_HOTKEY HkFindItem( _HKI( "Find Item" ), HK_FIND_ITEM, 'F' + GR_KB_CTRL, ID_FIND_ITEMS );
|
||||
static EDA_HOTKEY HkFindNextItem( _HKI( "Find Next Item" ), HK_FIND_NEXT_ITEM, WXK_F5,
|
||||
|
@ -210,6 +208,12 @@ static EDA_HOTKEY HkAutoplaceFields( _HKI( "Autoplace Fields" ), HK_AUTOPLACE_FI
|
|||
static EDA_HOTKEY HkUpdatePcbFromSch( _HKI( "Update PCB from Schematic" ), HK_UPDATE_PCB_FROM_SCH,
|
||||
WXK_F8 );
|
||||
|
||||
// Selection
|
||||
static EDA_HOTKEY HkSelectNode( _HKI( "Select Node" ), HK_SELECT_NODE,
|
||||
GR_KB_ALT + '3', ID_HOTKEY_SELECT_NODE);
|
||||
static EDA_HOTKEY HkSelectConnection( _HKI( "Select Connection" ), HK_SELECT_CONNECTION,
|
||||
GR_KB_ALT + '4', ID_HOTKEY_SELECT_CONNECTION );
|
||||
|
||||
// Higtlight connection
|
||||
static EDA_HOTKEY HkHighlightConnection( _HKI( "Highlight Connection" ), ID_HOTKEY_HIGHLIGHT,
|
||||
'B' + GR_KB_CTRL );
|
||||
|
@ -274,7 +278,7 @@ static EDA_HOTKEY* common_Hotkey_List[] =
|
|||
NULL
|
||||
};
|
||||
|
||||
// List of common hotkey descriptors, for the library vierwer
|
||||
// List of common hotkey descriptors, for the library viewer
|
||||
static EDA_HOTKEY* common_basic_Hotkey_List[] =
|
||||
{
|
||||
&HkHelp,
|
||||
|
@ -309,6 +313,8 @@ static EDA_HOTKEY* schematic_Hotkey_List[] =
|
|||
&HkEditComponentFootprint,
|
||||
&HkShowComponentDatasheet,
|
||||
&HkEditComponentWithLibedit,
|
||||
&HkSelectNode,
|
||||
&HkSelectConnection,
|
||||
&HkBeginWire,
|
||||
&HkBeginBus,
|
||||
&HkEndLineWireBus,
|
||||
|
@ -325,7 +331,6 @@ static EDA_HOTKEY* schematic_Hotkey_List[] =
|
|||
&HkUpdatePcbFromSch,
|
||||
&HkAutoplaceFields,
|
||||
&HkLeaveSheet,
|
||||
&HkDeleteNode,
|
||||
&HkHighlightConnection,
|
||||
&HkUnfoldBus,
|
||||
&HkCanvasCairo,
|
||||
|
@ -462,28 +467,6 @@ bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
|||
GetScreen()->m_O_Curseur = GetCrossHairPosition();
|
||||
break;
|
||||
|
||||
case ID_HOTKEY_HIGHLIGHT:
|
||||
if( notBusy )
|
||||
{
|
||||
cmd.SetId( ID_HIGHLIGHT_NET );
|
||||
GetEventHandler()->ProcessEvent( cmd );
|
||||
}
|
||||
break;
|
||||
|
||||
case HK_ZOOM_IN:
|
||||
case HK_ZOOM_OUT:
|
||||
case HK_ZOOM_REDRAW:
|
||||
case HK_ZOOM_CENTER:
|
||||
case HK_ZOOM_AUTO:
|
||||
case HK_ZOOM_SELECTION:
|
||||
case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving
|
||||
case HK_EDIT_PASTE:
|
||||
case HK_EDIT_COPY: // Copy block to paste buffer.
|
||||
case HK_EDIT_CUT:
|
||||
cmd.SetId( hotKey->m_IdMenuEvent );
|
||||
GetEventHandler()->ProcessEvent( cmd );
|
||||
break;
|
||||
|
||||
case HK_END_CURR_LINEWIREBUS:
|
||||
// this key terminates a new line/bus/wire in progress
|
||||
if( aItem && aItem->IsNew() &&
|
||||
|
|
|
@ -54,9 +54,11 @@ enum hotkey_id_command {
|
|||
HK_EDIT_COMPONENT_WITH_LIBEDIT,
|
||||
HK_MIRROR_X,
|
||||
HK_MIRROR_Y,
|
||||
HK_MOVE_COMPONENT_OR_ITEM,
|
||||
HK_DUPLICATE,
|
||||
HK_MOVE,
|
||||
HK_DRAG,
|
||||
HK_SELECT_NODE,
|
||||
HK_SELECT_CONNECTION,
|
||||
HK_ADD_NEW_COMPONENT,
|
||||
HK_ADD_NEW_POWER,
|
||||
HK_BEGIN_WIRE,
|
||||
|
|
|
@ -181,36 +181,14 @@ void SCH_EDIT_FRAME::addJunctionMenuEntries( wxMenu* aMenu, SCH_JUNCTION* aJunct
|
|||
AddMenuItem( aMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ),
|
||||
KiBitmap( break_line_xpm ) );
|
||||
}
|
||||
|
||||
if( screen->GetWireOrBus( aJunction->GetPosition() ) )
|
||||
{
|
||||
AddMenuItem( aMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ),
|
||||
KiBitmap( delete_node_xpm ) );
|
||||
AddMenuItem( aMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
|
||||
KiBitmap( delete_connection_xpm ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame )
|
||||
{
|
||||
SCH_SCREEN* screen = frame->GetScreen();
|
||||
wxPoint pos = frame->GetCrossHairPosition();
|
||||
wxString msg;
|
||||
|
||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ),
|
||||
KiBitmap( delete_node_xpm ) );
|
||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
|
||||
KiBitmap( delete_connection_xpm ) );
|
||||
|
||||
SCH_LINE* line = screen->GetWireOrBus( frame->GetCrossHairPosition() );
|
||||
|
||||
if( line && !line->IsEndPoint( frame->GetCrossHairPosition() ) )
|
||||
AddMenuItem( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ),
|
||||
KiBitmap( break_line_xpm ) );
|
||||
|
||||
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 );
|
||||
|
@ -229,8 +207,6 @@ void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame )
|
|||
wxPoint pos = frame->GetCrossHairPosition();
|
||||
wxString msg;
|
||||
|
||||
AddMenuItem( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Bus" ), KiBitmap( break_bus_xpm ) );
|
||||
|
||||
// TODO(JE) remove once real-time is enabled
|
||||
if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
|
||||
{
|
||||
|
|
|
@ -235,40 +235,6 @@ bool SCH_COLLECTOR::IsCorner() const
|
|||
}
|
||||
|
||||
|
||||
bool SCH_COLLECTOR::IsNode( bool aIncludePins ) const
|
||||
{
|
||||
for( size_t i = 0; i < m_List.size(); i++ )
|
||||
{
|
||||
SCH_ITEM* item = (SCH_ITEM*) m_List[ i ];
|
||||
KICAD_T type = item->Type();
|
||||
|
||||
if( type == SCH_JUNCTION_T )
|
||||
continue;
|
||||
|
||||
if( type == SCH_LINE_T )
|
||||
{
|
||||
if( item->GetLayer() != LAYER_WIRE )
|
||||
return false;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if( type == SCH_PIN_T )
|
||||
{
|
||||
if( !aIncludePins )
|
||||
return false;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Any other item types indicate that this collection is not a node.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool SCH_COLLECTOR::IsDraggableJunction() const
|
||||
{
|
||||
for( size_t i = 0; i < m_List.size(); i++ )
|
||||
|
|
|
@ -94,15 +94,6 @@ public:
|
|||
*/
|
||||
bool IsCorner() const;
|
||||
|
||||
/**
|
||||
* Function IsNode
|
||||
* tests if the collected items form a node.
|
||||
*
|
||||
* @param aIncludePins Indicate if component pin items should be included in the test.
|
||||
* @return True if the collected items form a node.
|
||||
*/
|
||||
bool IsNode( bool aIncludePins = true ) const;
|
||||
|
||||
/**
|
||||
* Function IsDraggableJunction
|
||||
* tests to see if the collected items form a draggable junction.
|
||||
|
|
|
@ -880,11 +880,6 @@ private:
|
|||
*/
|
||||
void NormalizeSchematicOnFirstLoad();
|
||||
|
||||
/**
|
||||
* Erase the last segment at the current mouse position.
|
||||
*/
|
||||
void DeleteConnection( bool DeleteFullConnection );
|
||||
|
||||
// Hierarchical Sheet & PinSheet
|
||||
void InstallHierarchyFrame( wxPoint& pos );
|
||||
|
||||
|
|
|
@ -22,17 +22,13 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file sch_field.h
|
||||
* @brief Definition of the SCH_FIELD class for Eeschema.
|
||||
*/
|
||||
|
||||
#ifndef CLASS_SCH_FIELD_H
|
||||
#define CLASS_SCH_FIELD_H
|
||||
|
||||
|
||||
#include <eda_text.h>
|
||||
#include <sch_item_struct.h>
|
||||
#include <template_fieldnames.h>
|
||||
#include <general.h>
|
||||
|
||||
|
||||
|
@ -74,6 +70,26 @@ public:
|
|||
return wxT( "SCH_FIELD" );
|
||||
}
|
||||
|
||||
bool IsType( const KICAD_T aScanTypes[] ) override
|
||||
{
|
||||
if( SCH_ITEM::IsType( aScanTypes ) )
|
||||
return true;
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
{
|
||||
if( *p == SCH_FIELD_LOCATE_REFERENCE_T && m_id == REFERENCE )
|
||||
return true;
|
||||
else if ( *p == SCH_FIELD_LOCATE_VALUE_T && m_id == VALUE )
|
||||
return true;
|
||||
else if ( *p == SCH_FIELD_LOCATE_FOOTPRINT_T && m_id == FOOTPRINT )
|
||||
return true;
|
||||
else if ( *p == SCH_FIELD_LOCATE_DATASHEET_T && m_id == DATASHEET )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetName
|
||||
* returns the field name.
|
||||
|
|
|
@ -22,18 +22,14 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file sch_line.h
|
||||
*/
|
||||
|
||||
#ifndef _SCH_LINE_H_
|
||||
#define _SCH_LINE_H_
|
||||
|
||||
|
||||
#include <sch_item_struct.h>
|
||||
|
||||
class NETLIST_OBJECT_LIST;
|
||||
|
||||
|
||||
/**
|
||||
* Segment description base class to describe items which have 2 end points (track, wire,
|
||||
* draw line ...)
|
||||
|
@ -66,6 +62,22 @@ public:
|
|||
return wxT( "SCH_LINE" );
|
||||
}
|
||||
|
||||
bool IsType( const KICAD_T aScanTypes[] ) override
|
||||
{
|
||||
if( SCH_ITEM::IsType( aScanTypes ) )
|
||||
return true;
|
||||
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
{
|
||||
if( *p == SCH_LINE_LOCATE_WIRE_T && m_Layer == LAYER_WIRE )
|
||||
return true;
|
||||
else if ( *p == SCH_LINE_LOCATE_BUS_T && m_Layer == LAYER_BUS )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsEndPoint( const wxPoint& aPoint ) const
|
||||
{
|
||||
return aPoint == m_start || aPoint == m_end;
|
||||
|
@ -74,17 +86,14 @@ public:
|
|||
bool IsNull() const { return m_start == m_end; }
|
||||
|
||||
wxPoint GetStartPoint() const { return m_start; }
|
||||
|
||||
void SetStartPoint( const wxPoint& aPosition ) { m_start = aPosition; }
|
||||
|
||||
wxPoint GetEndPoint() const { return m_end; }
|
||||
|
||||
void SetEndPoint( const wxPoint& aPosition ) { m_end = aPosition; }
|
||||
|
||||
int GetDefaultStyle() const;
|
||||
|
||||
void SetLineStyle( const int aStyle );
|
||||
|
||||
int GetLineStyle() const;
|
||||
|
||||
/// @return the style name from the style id
|
||||
|
@ -126,9 +135,7 @@ public:
|
|||
void MoveEnd( const wxPoint& aMoveVector );
|
||||
|
||||
void MirrorX( int aXaxis_position ) override;
|
||||
|
||||
void MirrorY( int aYaxis_position ) override;
|
||||
|
||||
void Rotate( wxPoint aPosition ) override;
|
||||
|
||||
/**
|
||||
|
@ -161,7 +168,6 @@ public:
|
|||
|
||||
bool IsStartDangling() const { return m_startIsDangling; }
|
||||
bool IsEndDangling() const { return m_endIsDangling; }
|
||||
|
||||
bool IsDangling() const override { return m_startIsDangling || m_endIsDangling; }
|
||||
|
||||
bool IsConnectable() const override;
|
||||
|
@ -179,11 +185,9 @@ public:
|
|||
bool operator <( const SCH_ITEM& aItem ) const override;
|
||||
|
||||
wxPoint GetPosition() const override { return m_start; }
|
||||
|
||||
void SetPosition( const wxPoint& aPosition ) override;
|
||||
|
||||
bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override;
|
||||
|
||||
bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override;
|
||||
|
||||
void Plot( PLOTTER* aPlotter ) override;
|
||||
|
|
|
@ -759,62 +759,6 @@ void SCH_SCREEN::GetHierarchicalItems( EDA_ITEMS& aItems )
|
|||
}
|
||||
|
||||
|
||||
// JEY TODO: obsolete once LibEdit is moved to modern toolset
|
||||
void SCH_SCREEN::SelectBlockItems()
|
||||
{
|
||||
PICKED_ITEMS_LIST* pickedlist = &m_BlockLocate.GetItems();
|
||||
|
||||
if( pickedlist->GetCount() == 0 )
|
||||
return;
|
||||
|
||||
ClearDrawingState();
|
||||
|
||||
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
|
||||
{
|
||||
SCH_ITEM* item = (SCH_ITEM*) pickedlist->GetPickedItem( ii );
|
||||
item->SetFlags( SELECTED );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// JEY TODO: obsolete once LibEdit is moved to modern toolset
|
||||
int SCH_SCREEN::UpdatePickList()
|
||||
{
|
||||
ITEM_PICKER picker;
|
||||
EDA_RECT area;
|
||||
unsigned count;
|
||||
|
||||
area.SetOrigin( m_BlockLocate.GetOrigin() );
|
||||
area.SetSize( m_BlockLocate.GetSize() );
|
||||
area.Normalize();
|
||||
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
// An item is picked if its bounding box intersects the reference area.
|
||||
if( item->HitTest( area ) &&
|
||||
( !m_BlockLocate.IsDragging() || item->IsType( SCH_COLLECTOR::DraggableItems ) ) )
|
||||
{
|
||||
picker.SetItem( item );
|
||||
m_BlockLocate.PushItem( picker );
|
||||
}
|
||||
}
|
||||
|
||||
// if the block is composed of one item,
|
||||
// select it as the current item
|
||||
count = m_BlockLocate.GetCount();
|
||||
if( count == 1 )
|
||||
{
|
||||
SetCurItem( (SCH_ITEM*) m_BlockLocate.GetItem( 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetCurItem( NULL );
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
bool SCH_SCREEN::TestDanglingEnds()
|
||||
{
|
||||
SCH_ITEM* item;
|
||||
|
@ -836,54 +780,17 @@ bool SCH_SCREEN::TestDanglingEnds()
|
|||
}
|
||||
|
||||
|
||||
int SCH_SCREEN::GetNode( const wxPoint& aPosition, EDA_ITEMS& aList )
|
||||
{
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
switch( item->Type() )
|
||||
{
|
||||
case SCH_LINE_T:
|
||||
case SCH_BUS_WIRE_ENTRY_T:
|
||||
case SCH_BUS_BUS_ENTRY_T:
|
||||
{
|
||||
if( item->HitTest( aPosition ) &&
|
||||
( item->GetLayer() == LAYER_BUS || item->GetLayer() == LAYER_WIRE ) )
|
||||
aList.push_back( item );
|
||||
break;
|
||||
}
|
||||
|
||||
case SCH_LABEL_T:
|
||||
case SCH_HIER_LABEL_T:
|
||||
case SCH_GLOBAL_LABEL_T:
|
||||
case SCH_SHEET_PIN_T:
|
||||
case SCH_JUNCTION_T:
|
||||
{
|
||||
if( item->HitTest( aPosition ) )
|
||||
aList.push_back( item );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (int) aList.size();
|
||||
}
|
||||
|
||||
|
||||
SCH_LINE* SCH_SCREEN::GetWireOrBus( const wxPoint& aPosition )
|
||||
{
|
||||
static KICAD_T types[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT };
|
||||
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( (item->Type() == SCH_LINE_T) && item->HitTest( aPosition )
|
||||
&& (item->GetLayer() == LAYER_BUS || item->GetLayer() == LAYER_WIRE) )
|
||||
{
|
||||
if( item->IsType( types ) && item->HitTest( aPosition ) )
|
||||
return (SCH_LINE*) item;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -988,150 +895,6 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxStri
|
|||
}
|
||||
|
||||
|
||||
int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aList,
|
||||
bool aFullConnection )
|
||||
{
|
||||
SCH_ITEM* item;
|
||||
EDA_ITEM* tmp;
|
||||
EDA_ITEMS list;
|
||||
|
||||
// Clear flags member for all items.
|
||||
ClearDrawingState();
|
||||
|
||||
if( GetNode( aPosition, list ) == 0 )
|
||||
return 0;
|
||||
|
||||
for( size_t i = 0; i < list.size(); i++ )
|
||||
{
|
||||
item = (SCH_ITEM*) list[ i ];
|
||||
item->SetFlags( SELECTEDNODE | STRUCT_DELETED );
|
||||
|
||||
/* Put this structure in the picked list: */
|
||||
ITEM_PICKER picker( item, UR_DELETED );
|
||||
aList.PushItem( picker );
|
||||
}
|
||||
|
||||
// Mark all wires, junctions, .. connected to the item(s) found.
|
||||
if( aFullConnection )
|
||||
{
|
||||
SCH_LINE* segment;
|
||||
|
||||
for( item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( !(item->GetFlags() & SELECTEDNODE) )
|
||||
continue;
|
||||
|
||||
if( item->Type() != SCH_LINE_T )
|
||||
continue;
|
||||
|
||||
MarkConnections( (SCH_LINE*) item );
|
||||
}
|
||||
|
||||
// Search all attached wires (i.e wire with one new dangling end )
|
||||
for( item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
bool noconnect = false;
|
||||
|
||||
if( item->GetFlags() & STRUCT_DELETED )
|
||||
continue; // Already seen
|
||||
|
||||
if( !(item->GetFlags() & CANDIDATE) )
|
||||
continue; // not a candidate
|
||||
|
||||
if( item->Type() != SCH_LINE_T )
|
||||
continue;
|
||||
|
||||
item->SetFlags( SKIP_STRUCT );
|
||||
|
||||
segment = (SCH_LINE*) item;
|
||||
|
||||
/* If the wire start point is connected to a wire that was already found
|
||||
* and now is not connected, add the wire to the list. */
|
||||
for( tmp = m_drawList.begin(); tmp; tmp = tmp->Next() )
|
||||
{
|
||||
// Ensure tmp is a previously deleted segment:
|
||||
if( ( tmp->GetFlags() & STRUCT_DELETED ) == 0 )
|
||||
continue;
|
||||
|
||||
if( tmp->Type() != SCH_LINE_T )
|
||||
continue;
|
||||
|
||||
SCH_LINE* testSegment = (SCH_LINE*) tmp;
|
||||
|
||||
// Test for segment connected to the previously deleted segment:
|
||||
if( testSegment->IsEndPoint( segment->GetStartPoint() ) )
|
||||
break;
|
||||
}
|
||||
|
||||
// when tmp != NULL, segment is a new candidate:
|
||||
// put it in deleted list if
|
||||
// the start point is not connected to another item (like pin)
|
||||
if( tmp && !CountConnectedItems( segment->GetStartPoint(), true ) )
|
||||
noconnect = true;
|
||||
|
||||
/* If the wire end point is connected to a wire that has already been found
|
||||
* and now is not connected, add the wire to the list. */
|
||||
for( tmp = m_drawList.begin(); tmp; tmp = tmp->Next() )
|
||||
{
|
||||
// Ensure tmp is a previously deleted segment:
|
||||
if( ( tmp->GetFlags() & STRUCT_DELETED ) == 0 )
|
||||
continue;
|
||||
|
||||
if( tmp->Type() != SCH_LINE_T )
|
||||
continue;
|
||||
|
||||
SCH_LINE* testSegment = (SCH_LINE*) tmp;
|
||||
|
||||
// Test for segment connected to the previously deleted segment:
|
||||
if( testSegment->IsEndPoint( segment->GetEndPoint() ) )
|
||||
break;
|
||||
}
|
||||
|
||||
// when tmp != NULL, segment is a new candidate:
|
||||
// put it in deleted list if
|
||||
// the end point is not connected to another item (like pin)
|
||||
if( tmp && !CountConnectedItems( segment->GetEndPoint(), true ) )
|
||||
noconnect = true;
|
||||
|
||||
item->ClearFlags( SKIP_STRUCT );
|
||||
|
||||
if( noconnect )
|
||||
{
|
||||
item->SetFlags( STRUCT_DELETED );
|
||||
|
||||
ITEM_PICKER picker( item, UR_DELETED );
|
||||
aList.PushItem( picker );
|
||||
|
||||
item = m_drawList.begin();
|
||||
}
|
||||
}
|
||||
|
||||
for( item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( item->GetFlags() & STRUCT_DELETED )
|
||||
continue;
|
||||
|
||||
if( item->Type() != SCH_LABEL_T )
|
||||
continue;
|
||||
|
||||
tmp = GetWireOrBus( ( (SCH_TEXT*) item )->GetPosition() );
|
||||
|
||||
if( tmp && ( tmp->GetFlags() & STRUCT_DELETED ) )
|
||||
{
|
||||
item->SetFlags( STRUCT_DELETED );
|
||||
|
||||
ITEM_PICKER picker( item, UR_DELETED );
|
||||
aList.PushItem( picker );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ClearDrawingState();
|
||||
|
||||
return aList.GetCount();
|
||||
}
|
||||
|
||||
|
||||
void SCH_SCREEN::AddBusAlias( std::shared_ptr<BUS_ALIAS> aAlias )
|
||||
{
|
||||
m_aliases.insert( aAlias );
|
||||
|
|
|
@ -302,19 +302,6 @@ public:
|
|||
*/
|
||||
void MarkConnections( SCH_LINE* aSegment );
|
||||
|
||||
/**
|
||||
* Adds all of the wires and junctions to \a aList that make up a connection to the
|
||||
* object at \a aPosition.
|
||||
*
|
||||
* @param aPosition The position of the first connection object in drawing units.
|
||||
* @param aList The pick list to add the connect item to.
|
||||
* @param aFullConnection If true all the objects that make up this connection are
|
||||
* add to \a aList. Otherwise, only the objects up to the first
|
||||
* node are added.
|
||||
* @return The number of items added to \a aList.
|
||||
*/
|
||||
int GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aList, bool aFullConnection );
|
||||
|
||||
/* full undo redo management : */
|
||||
// use BASE_SCREEN::PushCommandToUndoList( PICKED_ITEMS_LIST* aItem )
|
||||
// use BASE_SCREEN::PushCommandToRedoList( PICKED_ITEMS_LIST* aItem )
|
||||
|
@ -422,15 +409,6 @@ public:
|
|||
*/
|
||||
void GetHierarchicalItems( EDA_ITEMS& aItems );
|
||||
|
||||
/**
|
||||
* Return all the items at \a aPosition that form a node.
|
||||
*
|
||||
* @param aPosition The wxPoint to test for node items.
|
||||
* @param aList A #EDA_ITEMS container to place the items found.
|
||||
* @return The number of node items found at \a aPosition.
|
||||
*/
|
||||
int GetNode( const wxPoint& aPosition, EDA_ITEMS& aList );
|
||||
|
||||
/**
|
||||
* Return a wire or bus item located at \a aPosition.
|
||||
*
|
||||
|
@ -488,21 +466,6 @@ public:
|
|||
bool SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxString& aReference,
|
||||
const wxString& aFootPrint, bool aSetVisible );
|
||||
|
||||
/**
|
||||
* Create a list of items found when a block command is initiated.
|
||||
*
|
||||
* The items selected depend on the block command. If the drag block command is issued,
|
||||
* then any items connected to items in the block are also selected.
|
||||
*/
|
||||
void SelectBlockItems();
|
||||
|
||||
/**
|
||||
* Add all the items in the screen within the block selection rectangle to the pick list.
|
||||
*
|
||||
* @return The number of items in the pick list.
|
||||
*/
|
||||
int UpdatePickList();
|
||||
|
||||
/**
|
||||
* Adds a bus alias definition (and transfers ownership of the pointer)
|
||||
*/
|
||||
|
|
|
@ -66,10 +66,7 @@
|
|||
case ID_POPUP_SCH_CLEANUP_SHEET:
|
||||
case ID_POPUP_SCH_RESIZE_SHEET:
|
||||
case ID_POPUP_IMPORT_HLABEL_TO_SHEETPIN:
|
||||
case ID_POPUP_SCH_INIT_CMP:
|
||||
case ID_POPUP_SCH_EDIT_CONVERT_CMP:
|
||||
case ID_POPUP_SCH_DELETE_NODE:
|
||||
case ID_POPUP_SCH_DELETE_CONNECTION:
|
||||
case ID_POPUP_SCH_ENTER_SHEET:
|
||||
case ID_POPUP_SCH_LEAVE_SHEET:
|
||||
case ID_POPUP_SCH_ADD_JUNCTION:
|
||||
|
@ -107,27 +104,6 @@
|
|||
}
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_DELETE_NODE:
|
||||
case ID_POPUP_SCH_DELETE_CONNECTION:
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
DeleteConnection( id == ID_POPUP_SCH_DELETE_CONNECTION );
|
||||
SchematicCleanUp( true );
|
||||
screen->SetCurItem( NULL );
|
||||
SetRepeatItem( NULL );
|
||||
|
||||
TestDanglingEnds();
|
||||
m_canvas->Refresh();
|
||||
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_BREAK_WIRE:
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
BreakSegments( GetCrossHairPosition() );
|
||||
TestDanglingEnds();
|
||||
m_canvas->Refresh();
|
||||
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_CLEANUP_SHEET:
|
||||
if( item != NULL && item->Type() == SCH_SHEET_T )
|
||||
{
|
||||
|
@ -151,10 +127,6 @@
|
|||
}
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_INIT_CMP:
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_EDIT_CONVERT_CMP:
|
||||
// Ensure the struct is a component (could be a struct of a component, like Field, text..)
|
||||
if( item && item->Type() == SCH_COMPONENT_T )
|
||||
|
@ -237,21 +209,6 @@ void SCH_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
|
|||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::DeleteConnection( bool aFullConnection )
|
||||
{
|
||||
PICKED_ITEMS_LIST pickList;
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
wxPoint pos = GetCrossHairPosition();
|
||||
|
||||
if( screen->GetConnection( pos, pickList, aFullConnection ) != 0 )
|
||||
{
|
||||
DeleteItemsInList( pickList );
|
||||
SchematicCleanUp( true );
|
||||
OnModify();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::SelectAllFromSheet( wxCommandEvent& aEvent )
|
||||
{
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
|
|
|
@ -250,6 +250,12 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
|||
|
||||
case ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP:
|
||||
return SCH_ACTIONS::editWithSymbolEditor.MakeEvent();
|
||||
|
||||
case ID_HOTKEY_SELECT_NODE:
|
||||
return SCH_ACTIONS::selectNode.MakeEvent();
|
||||
|
||||
case ID_HOTKEY_SELECT_CONNECTION:
|
||||
return SCH_ACTIONS::selectConnection.MakeEvent();
|
||||
}
|
||||
|
||||
return OPT<TOOL_EVENT>();
|
||||
|
|
|
@ -46,19 +46,23 @@ public:
|
|||
/// Activation of the selection tool
|
||||
static TOOL_ACTION selectionActivate;
|
||||
|
||||
/// Select a single item under the cursor position
|
||||
static TOOL_ACTION selectionCursor;
|
||||
/// Select the junction, wire or bus segment under the cursor.
|
||||
static TOOL_ACTION selectNode;
|
||||
|
||||
/// If current selection is a wire or bus, expand to entire connection.
|
||||
/// Otherwise, select connection under cursor.
|
||||
static TOOL_ACTION selectConnection;
|
||||
|
||||
/// Clears the current selection
|
||||
static TOOL_ACTION selectionClear;
|
||||
static TOOL_ACTION clearSelection;
|
||||
|
||||
/// Selects an item (specified as the event parameter).
|
||||
static TOOL_ACTION selectItem;
|
||||
static TOOL_ACTION unselectItem;
|
||||
static TOOL_ACTION addItemToSel;
|
||||
static TOOL_ACTION removeItemFromSel;
|
||||
|
||||
/// Selects a list of items (specified as the event parameter)
|
||||
static TOOL_ACTION selectItems;
|
||||
static TOOL_ACTION unselectItems;
|
||||
static TOOL_ACTION addItemsToSel;
|
||||
static TOOL_ACTION removeItemsFromSel;
|
||||
|
||||
/// Runs a selection menu to select from a list of items
|
||||
static TOOL_ACTION selectionMenu;
|
||||
|
@ -142,6 +146,8 @@ public:
|
|||
static TOOL_ACTION toHLabel;
|
||||
static TOOL_ACTION toGLabel;
|
||||
static TOOL_ACTION toText;
|
||||
static TOOL_ACTION breakWire;
|
||||
static TOOL_ACTION breakBus;
|
||||
|
||||
/// Inspection
|
||||
static TOOL_ACTION showDatasheet;
|
||||
|
|
|
@ -272,7 +272,7 @@ void SCH_DRAWING_TOOL::Reset( RESET_REASON aReason )
|
|||
|
||||
int SCH_DRAWING_TOOL::AddJunction( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
|
||||
m_frame->GetCanvas()->MoveCursorToCrossHair();
|
||||
m_frame->AddJunction( m_frame->GetCrossHairPosition() );
|
||||
|
@ -295,7 +295,7 @@ int SCH_DRAWING_TOOL::AddGlobalLabel( const TOOL_EVENT& aEvent )
|
|||
|
||||
int SCH_DRAWING_TOOL::doAddItem( KICAD_T aType )
|
||||
{
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
|
||||
SCH_ITEM* item = nullptr;
|
||||
|
||||
|
@ -345,7 +345,7 @@ int SCH_DRAWING_TOOL::doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER
|
|||
{
|
||||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
||||
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
m_controls->ShowCursor( true );
|
||||
m_controls->SetSnapping( true );
|
||||
|
||||
|
@ -368,7 +368,7 @@ int SCH_DRAWING_TOOL::doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER
|
|||
{
|
||||
if( aComponent )
|
||||
{
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
getModel<SCH_SCREEN>()->SetCurItem( nullptr );
|
||||
m_view->ClearPreview();
|
||||
m_view->ClearHiddenFlags();
|
||||
|
@ -428,7 +428,7 @@ int SCH_DRAWING_TOOL::doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER
|
|||
m_view->ClearPreview();
|
||||
m_view->AddToPreview( aComponent->Clone() );
|
||||
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectItem, true, aComponent );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::addItemToSel, true, aComponent );
|
||||
|
||||
m_controls->SetCursorPosition( cursorPos, false );
|
||||
}
|
||||
|
@ -475,7 +475,7 @@ int SCH_DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
|
||||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
||||
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
m_controls->ShowCursor( true );
|
||||
m_controls->SetSnapping( true );
|
||||
|
||||
|
@ -498,7 +498,7 @@ int SCH_DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
if( image )
|
||||
{
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
getModel<SCH_SCREEN>()->SetCurItem( nullptr );
|
||||
m_view->ClearPreview();
|
||||
m_view->ClearHiddenFlags();
|
||||
|
@ -551,7 +551,7 @@ int SCH_DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
m_view->ClearPreview();
|
||||
m_view->AddToPreview( image->Clone() );
|
||||
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectItem, true, image );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::addItemToSel, true, image );
|
||||
|
||||
m_controls->SetCursorPosition( cursorPos, false );
|
||||
}
|
||||
|
@ -620,7 +620,7 @@ int SCH_DRAWING_TOOL::PlaceBusBusEntry( const TOOL_EVENT& aEvent )
|
|||
|
||||
int SCH_DRAWING_TOOL::doSingleClickPlace( KICAD_T aType )
|
||||
{
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
m_controls->ShowCursor( true );
|
||||
m_controls->SetSnapping( true );
|
||||
|
||||
|
@ -735,7 +735,7 @@ int SCH_DRAWING_TOOL::doTwoClickPlace( KICAD_T aType )
|
|||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
||||
SCH_ITEM* item = nullptr;
|
||||
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
m_controls->ShowCursor( true );
|
||||
m_controls->SetSnapping( true );
|
||||
|
||||
|
@ -750,7 +750,7 @@ int SCH_DRAWING_TOOL::doTwoClickPlace( KICAD_T aType )
|
|||
{
|
||||
if( item )
|
||||
{
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
getModel<SCH_SCREEN>()->SetCurItem( nullptr );
|
||||
m_view->ClearPreview();
|
||||
m_view->ClearHiddenFlags();
|
||||
|
@ -806,7 +806,7 @@ int SCH_DRAWING_TOOL::doTwoClickPlace( KICAD_T aType )
|
|||
|
||||
if( item )
|
||||
{
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectItem, true, item );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::addItemToSel, true, item );
|
||||
|
||||
item->SetFlags( IS_MOVED );
|
||||
m_view->ClearPreview();
|
||||
|
@ -1132,7 +1132,7 @@ int SCH_DRAWING_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
|
|||
bool forceHV = m_frame->GetForceHVLines();
|
||||
SCH_SCREEN* screen = m_frame->GetScreen();
|
||||
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
m_controls->ShowCursor( true );
|
||||
m_controls->SetSnapping( true );
|
||||
|
||||
|
@ -1454,7 +1454,7 @@ int SCH_DRAWING_TOOL::ResizeSheet( const TOOL_EVENT& aEvent )
|
|||
|
||||
int SCH_DRAWING_TOOL::doDrawSheet( SCH_SHEET *aSheet )
|
||||
{
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
m_controls->ShowCursor( true );
|
||||
m_controls->SetSnapping( true );
|
||||
|
||||
|
|
|
@ -44,10 +44,11 @@
|
|||
#include <list_operations.h>
|
||||
#include <eeschema_id.h>
|
||||
#include <status_popup.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include "sch_drawing_tool.h"
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::move( "eeschema.InteractiveEdit.move",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MOVE_COMPONENT_OR_ITEM ),
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MOVE ),
|
||||
_( "Move" ), _( "Moves the selected item(s)" ),
|
||||
move_xpm, AF_ACTIVATE );
|
||||
|
||||
|
@ -151,6 +152,15 @@ TOOL_ACTION SCH_ACTIONS::deleteItemCursor( "eeschema.InteractiveEdit.deleteItemC
|
|||
_( "DoDelete Items" ), _( "DoDelete clicked items" ),
|
||||
nullptr, AF_ACTIVATE );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::breakWire( "eeschema.InteractiveEdit.breakWire",
|
||||
AS_GLOBAL, 0,
|
||||
_( "Break Wire" ), _( "Divide a wire into segments which can be dragged independently" ),
|
||||
break_line_xpm );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::breakBus( "eeschema.InteractiveEdit.breakBus",
|
||||
AS_GLOBAL, 0,
|
||||
_( "Break Bus" ), _( "Divide a bus into segments which can be dragged independently" ),
|
||||
break_line_xpm );
|
||||
|
||||
|
||||
SCH_EDIT_TOOL::SCH_EDIT_TOOL() :
|
||||
|
@ -239,7 +249,7 @@ bool SCH_EDIT_TOOL::Init()
|
|||
};
|
||||
|
||||
auto notJustMarkersCondition = SELECTION_CONDITIONS::MoreThan( 0 )
|
||||
&& !SELECTION_CONDITIONS::OnlyType( SCH_MARKER_T );
|
||||
&& ! SELECTION_CONDITIONS::OnlyType( SCH_MARKER_T );
|
||||
|
||||
auto toLabelCondition = SELECTION_CONDITIONS::Count( 1 )
|
||||
&& ( SELECTION_CONDITIONS::HasType( SCH_GLOBAL_LABEL_T )
|
||||
|
@ -264,10 +274,10 @@ bool SCH_EDIT_TOOL::Init()
|
|||
auto entryCondition = SELECTION_CONDITIONS::HasType( SCH_BUS_WIRE_ENTRY_T )
|
||||
|| SELECTION_CONDITIONS::HasType( SCH_BUS_BUS_ENTRY_T );
|
||||
|
||||
auto singleComponentCondition = SELECTION_CONDITIONS::OnlyType( SCH_COMPONENT_T )
|
||||
&& SELECTION_CONDITIONS::Count( 1 );
|
||||
auto singleComponentCondition = SELECTION_CONDITIONS::Count( 1 )
|
||||
&& SELECTION_CONDITIONS::OnlyType( SCH_COMPONENT_T );
|
||||
|
||||
auto singleSymbolCondition = [] (const SELECTION& aSel ) {
|
||||
auto singleSymbolCondition = [] ( const SELECTION& aSel ) {
|
||||
if( aSel.GetSize() == 1 )
|
||||
{
|
||||
SCH_COMPONENT* comp = dynamic_cast<SCH_COMPONENT*>( aSel.GetItem( 0 ) );
|
||||
|
@ -282,10 +292,30 @@ bool SCH_EDIT_TOOL::Init()
|
|||
return false;
|
||||
};
|
||||
|
||||
CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
|
||||
auto wireTool = [ this ] ( const SELECTION& aSel ) {
|
||||
return ( m_frame->GetToolId() == ID_WIRE_BUTT
|
||||
|| m_frame->GetToolId() == ID_JUNCTION_BUTT );
|
||||
};
|
||||
|
||||
auto busTool = [ this ] ( const SELECTION& aSel ) {
|
||||
return ( m_frame->GetToolId() == ID_BUS_BUTT
|
||||
|| m_frame->GetToolId() == ID_JUNCTION_BUTT );
|
||||
};
|
||||
|
||||
auto wireOrBusTool = wireTool || busTool;
|
||||
|
||||
auto wireSelectionCondition = SELECTION_CONDITIONS::MoreThan( 0 )
|
||||
&& SELECTION_CONDITIONS::OnlyType( SCH_LINE_LOCATE_WIRE_T );
|
||||
|
||||
auto busSelectionCondition = SELECTION_CONDITIONS::MoreThan( 0 )
|
||||
&& SELECTION_CONDITIONS::OnlyType( SCH_LINE_LOCATE_BUS_T );
|
||||
|
||||
auto wireOrBusSelectionCondition = wireSelectionCondition || busSelectionCondition;
|
||||
|
||||
// Build the edit tool menu (shown when moving or dragging)
|
||||
//
|
||||
CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
|
||||
|
||||
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
|
||||
|
||||
ctxMenu.AddSeparator( SELECTION_CONDITIONS::NotEmpty );
|
||||
|
@ -328,6 +358,10 @@ bool SCH_EDIT_TOOL::Init()
|
|||
drawingMenu.AddItem( SCH_ACTIONS::toHLabel, toHLabelCondition, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::toGLabel, toGLabelCondition, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::toText, toTextlCondition, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::selectNode, wireOrBusTool, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::selectConnection, wireOrBusTool, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::breakWire, wireTool, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::breakBus, busTool, 200 );
|
||||
|
||||
// Add editing actions to the selection tool menu
|
||||
//
|
||||
|
@ -354,6 +388,9 @@ 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 );
|
||||
|
||||
selToolMenu.AddSeparator( SELECTION_CONDITIONS::NotEmpty, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty, 200 );
|
||||
|
@ -597,7 +634,7 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( restore_state )
|
||||
{
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
m_frame->RollbackSchematicFromUndo();
|
||||
return 0;
|
||||
}
|
||||
|
@ -608,7 +645,7 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
m_frame->OnModify();
|
||||
|
||||
if( unselect )
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -688,7 +725,7 @@ void SCH_EDIT_TOOL::selectConnectedDragItems( SCH_ITEM* aSourceItem, wxPoint aPo
|
|||
|
||||
if( doSelect )
|
||||
{
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectItem, true, item );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::addItemToSel, true, item );
|
||||
saveCopyInUndoList( item, UR_CHANGED, true );
|
||||
}
|
||||
}
|
||||
|
@ -876,7 +913,7 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
|
|||
if( !item->IsMoving() )
|
||||
{
|
||||
if( selection.IsHover() )
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
|
||||
if( connections )
|
||||
m_frame->TestDanglingEnds();
|
||||
|
@ -1017,7 +1054,7 @@ int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
|
|||
if( !item->IsMoving() )
|
||||
{
|
||||
if( selection.IsHover() )
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
|
||||
if( connections )
|
||||
m_frame->TestDanglingEnds();
|
||||
|
@ -1108,8 +1145,8 @@ int SCH_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
|
|||
screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
|
||||
}
|
||||
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectItems, true, &newItems );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::addItemsToSel, true, &newItems );
|
||||
|
||||
TOOL_EVENT evt = SCH_ACTIONS::move.MakeEvent();
|
||||
Main( evt );
|
||||
|
@ -1125,7 +1162,7 @@ int SCH_EDIT_TOOL::RepeatDrawItem( const TOOL_EVENT& aEvent )
|
|||
if( !sourceItem )
|
||||
return 0;
|
||||
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
|
||||
SCH_ITEM* newItem = (SCH_ITEM*) sourceItem->Clone();
|
||||
bool performDrag = false;
|
||||
|
@ -1150,7 +1187,7 @@ int SCH_EDIT_TOOL::RepeatDrawItem( const TOOL_EVENT& aEvent )
|
|||
m_frame->AddToScreen( newItem );
|
||||
m_frame->SaveCopyInUndoList( newItem, UR_NEW );
|
||||
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectItem, true, newItem );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::addItemToSel, true, newItem );
|
||||
|
||||
if( performDrag )
|
||||
{
|
||||
|
@ -1180,7 +1217,7 @@ int SCH_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
|
|||
return 0;
|
||||
|
||||
// As we are about to remove items, they have to be removed from the selection first
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
|
||||
for( unsigned ii = 0; ii < selectionCopy.GetSize(); ii++ )
|
||||
{
|
||||
|
@ -1210,7 +1247,7 @@ static bool deleteItem( SCH_EDIT_FRAME* aFrame, const VECTOR2D& aPosition )
|
|||
SCH_SELECTION_TOOL* selectionTool = aFrame->GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
wxCHECK( selectionTool, false );
|
||||
|
||||
aFrame->GetToolManager()->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
aFrame->GetToolManager()->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
|
||||
SCH_ITEM* item = selectionTool->SelectPoint( aPosition );
|
||||
|
||||
|
@ -1461,6 +1498,22 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int SCH_EDIT_TOOL::BreakWire( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
VECTOR2I cursorPos = m_controls->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
|
||||
|
||||
if( m_frame->BreakSegments( (wxPoint) cursorPos ) )
|
||||
{
|
||||
m_frame->TestDanglingEnds();
|
||||
|
||||
m_frame->OnModify();
|
||||
m_frame->GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_TOOL::updateView( EDA_ITEM* aItem )
|
||||
{
|
||||
KICAD_T itemType = aItem->Type();
|
||||
|
@ -1508,4 +1561,7 @@ void SCH_EDIT_TOOL::setTransitions()
|
|||
Go( &SCH_EDIT_TOOL::ChangeTextType, SCH_ACTIONS::toHLabel.MakeEvent() );
|
||||
Go( &SCH_EDIT_TOOL::ChangeTextType, SCH_ACTIONS::toGLabel.MakeEvent() );
|
||||
Go( &SCH_EDIT_TOOL::ChangeTextType, SCH_ACTIONS::toText.MakeEvent() );
|
||||
|
||||
Go( &SCH_EDIT_TOOL::BreakWire, SCH_ACTIONS::breakWire.MakeEvent() );
|
||||
Go( &SCH_EDIT_TOOL::BreakWire, SCH_ACTIONS::breakBus.MakeEvent() );
|
||||
}
|
||||
|
|
|
@ -68,6 +68,8 @@ public:
|
|||
int ChangeShape( const TOOL_EVENT& aEvent );
|
||||
int ChangeTextType( const TOOL_EVENT& aEvent );
|
||||
|
||||
int BreakWire( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Function DoDelete()
|
||||
*
|
||||
|
|
|
@ -296,19 +296,19 @@ int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
|
|||
#endif /* KICAD_SPICE */
|
||||
|
||||
|
||||
// A magic cookie token for clearing the highlight
|
||||
// A singleton reference for clearing the highlight
|
||||
static VECTOR2D CLEAR;
|
||||
|
||||
|
||||
// TODO(JE) Probably use netcode rather than connection name here eventually
|
||||
static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
|
||||
{
|
||||
SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
|
||||
wxString netName;
|
||||
EDA_ITEMS nodeList;
|
||||
bool retVal = true;
|
||||
SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
|
||||
SCH_SELECTION_TOOL* selTool = aToolMgr->GetTool<SCH_SELECTION_TOOL>();
|
||||
wxString netName;
|
||||
bool retVal = true;
|
||||
|
||||
if( aPosition != CLEAR && editFrame->GetScreen()->GetNode( (wxPoint) aPosition, nodeList ) )
|
||||
if( aPosition != CLEAR )
|
||||
{
|
||||
if( TestDuplicateSheetNames( false ) > 0 )
|
||||
{
|
||||
|
@ -317,14 +317,10 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
|
|||
}
|
||||
else
|
||||
{
|
||||
if( auto item = dynamic_cast<SCH_ITEM*>( nodeList[0] ) )
|
||||
{
|
||||
if( item->Connection( *g_CurrentSheet ) )
|
||||
{
|
||||
netName = item->Connection( *g_CurrentSheet )->Name();
|
||||
editFrame->SetStatusText( wxString::Format( _( "Highlighted net: %s" ), UnescapeString( netName ) ) );
|
||||
}
|
||||
}
|
||||
SCH_ITEM* item = selTool->GetNode( aPosition );
|
||||
|
||||
if( item && item->Connection( *g_CurrentSheet ) )
|
||||
netName = item->Connection( *g_CurrentSheet )->Name();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -336,7 +332,7 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
|
|||
else
|
||||
{
|
||||
editFrame->SendCrossProbeNetName( netName );
|
||||
editFrame->SetStatusText( wxString::Format( _( "Selected net: %s" ),
|
||||
editFrame->SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
|
||||
UnescapeString( netName ) ) );
|
||||
}
|
||||
|
||||
|
@ -351,9 +347,9 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
|
|||
int SCH_EDITOR_CONTROL::HighlightNet( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||
VECTOR2D gridPosition = controls->GetCursorPosition( true );
|
||||
VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
|
||||
|
||||
highlightNet( m_toolMgr, gridPosition );
|
||||
highlightNet( m_toolMgr, cursorPos );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -617,8 +613,8 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
|||
// Now clear the previous selection, select the pasted items, and fire up the "move"
|
||||
// tool.
|
||||
//
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectItems, true, &loadedItems );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::addItemsToSel, true, &loadedItems );
|
||||
|
||||
SELECTION& selection = selTool->GetSelection();
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ int SCH_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
|
||||
while( OPT_TOOL_EVENT evt = Wait() )
|
||||
{
|
||||
VECTOR2I cursorPos = controls->GetCursorPosition( true );
|
||||
VECTOR2I cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||
|
||||
if( evt->IsClick( BUT_LEFT ) )
|
||||
{
|
||||
|
|
|
@ -42,30 +42,36 @@
|
|||
#include <painter.h>
|
||||
#include <eeschema_id.h>
|
||||
#include <menus_helpers.h>
|
||||
#include <hotkeys.h>
|
||||
|
||||
// Selection tool actions
|
||||
TOOL_ACTION SCH_ACTIONS::selectionActivate( "eeschema.InteractiveSelection",
|
||||
AS_GLOBAL, 0, "", "", NULL, AF_ACTIVATE ); // No description, not shown anywhere
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::selectionCursor( "eeschema.InteractiveSelection.Cursor",
|
||||
AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere
|
||||
TOOL_ACTION SCH_ACTIONS::selectNode( "eeschema.InteractiveSelection.SelectNode",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SELECT_NODE ),
|
||||
_( "Select Node" ), _( "Select a connection item under the cursor" ), nullptr );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::selectConnection( "eeschema.InteractiveSelection.SelectConnection",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SELECT_CONNECTION ),
|
||||
_( "Select Node" ), _( "Select a connection item under the cursor" ), nullptr );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::selectionMenu( "eeschema.InteractiveSelection.SelectionMenu",
|
||||
AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::selectItem( "eeschema.InteractiveSelection.SelectItem",
|
||||
TOOL_ACTION SCH_ACTIONS::addItemToSel( "eeschema.InteractiveSelection.AddItemToSel",
|
||||
AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::selectItems( "eeschema.InteractiveSelection.SelectItems",
|
||||
TOOL_ACTION SCH_ACTIONS::addItemsToSel( "eeschema.InteractiveSelection.AddItemsToSel",
|
||||
AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::unselectItem( "eeschema.InteractiveSelection.UnselectItem",
|
||||
TOOL_ACTION SCH_ACTIONS::removeItemFromSel( "eeschema.InteractiveSelection.RemoveItemFromSel",
|
||||
AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::unselectItems( "eeschema.InteractiveSelection.UnselectItems",
|
||||
TOOL_ACTION SCH_ACTIONS::removeItemsFromSel( "eeschema.InteractiveSelection.RemoveItemsFromSel",
|
||||
AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::selectionClear( "eeschema.InteractiveSelection.Clear",
|
||||
TOOL_ACTION SCH_ACTIONS::clearSelection( "eeschema.InteractiveSelection.ClearSelection",
|
||||
AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere
|
||||
|
||||
|
||||
|
@ -324,7 +330,7 @@ SELECTION& SCH_SELECTION_TOOL::RequestSelection( const KICAD_T aFilterList[] )
|
|||
{
|
||||
if( m_selection.Empty() )
|
||||
{
|
||||
VECTOR2D cursorPos = getViewControls()->GetCursorPosition( false );
|
||||
VECTOR2D cursorPos = getViewControls()->GetCursorPosition( true );
|
||||
|
||||
clearSelection();
|
||||
SelectPoint( cursorPos, aFilterList );
|
||||
|
@ -337,32 +343,8 @@ SELECTION& SCH_SELECTION_TOOL::RequestSelection( const KICAD_T aFilterList[] )
|
|||
for( int i = m_selection.GetSize() - 1; i >= 0; --i )
|
||||
{
|
||||
SCH_ITEM* item = (SCH_ITEM*) m_selection.GetItem( i );
|
||||
KICAD_T matchType;
|
||||
bool match = false;
|
||||
|
||||
if( item->Type() == SCH_FIELD_T )
|
||||
{
|
||||
SCH_FIELD* field = (SCH_FIELD*) item;
|
||||
|
||||
for( const KICAD_T* p = aFilterList; (matchType = *p) != EOT && !match; ++p )
|
||||
{
|
||||
switch( matchType )
|
||||
{
|
||||
case SCH_FIELD_LOCATE_REFERENCE_T: match = field->GetId() == REFERENCE; break;
|
||||
case SCH_FIELD_LOCATE_VALUE_T: match = field->GetId() == VALUE; break;
|
||||
case SCH_FIELD_LOCATE_FOOTPRINT_T: match = field->GetId() == FOOTPRINT; break;
|
||||
|
||||
default: match = ( item->Type() == matchType ); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( const KICAD_T* p = aFilterList; (matchType = *p) != EOT && !match; ++p )
|
||||
match = ( item->Type() == matchType );
|
||||
}
|
||||
|
||||
if( !match )
|
||||
if( !item->IsType( aFilterList ) )
|
||||
toggleSelection( item );
|
||||
}
|
||||
|
||||
|
@ -371,20 +353,6 @@ SELECTION& SCH_SELECTION_TOOL::RequestSelection( const KICAD_T aFilterList[] )
|
|||
}
|
||||
|
||||
|
||||
bool SCH_SELECTION_TOOL::selectCursor( const KICAD_T aFilterList[], bool aForceSelect )
|
||||
{
|
||||
if( aForceSelect || m_selection.Empty() )
|
||||
{
|
||||
VECTOR2D cursorPos = getViewControls()->GetCursorPosition( false );
|
||||
|
||||
clearSelection();
|
||||
SelectPoint( cursorPos, aFilterList );
|
||||
}
|
||||
|
||||
return !m_selection.Empty();
|
||||
}
|
||||
|
||||
|
||||
bool SCH_SELECTION_TOOL::selectMultiple()
|
||||
{
|
||||
bool cancelled = false; // Was the tool cancelled while it was running?
|
||||
|
@ -508,7 +476,67 @@ bool SCH_SELECTION_TOOL::selectMultiple()
|
|||
}
|
||||
|
||||
|
||||
int SCH_SELECTION_TOOL::SelectItems( const TOOL_EVENT& aEvent )
|
||||
static KICAD_T nodeTypes[] =
|
||||
{
|
||||
SCH_LINE_LOCATE_WIRE_T,
|
||||
SCH_LINE_LOCATE_BUS_T,
|
||||
SCH_BUS_WIRE_ENTRY_T,
|
||||
SCH_BUS_BUS_ENTRY_T,
|
||||
SCH_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
SCH_SHEET_PIN_T,
|
||||
SCH_JUNCTION_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
SCH_ITEM* SCH_SELECTION_TOOL::GetNode( VECTOR2I aPosition )
|
||||
{
|
||||
SCH_COLLECTOR collector;
|
||||
|
||||
collector.Collect( m_frame->GetScreen()->GetDrawItems(), nodeTypes, (wxPoint) aPosition );
|
||||
|
||||
return collector.GetCount() ? collector[ 0 ] : nullptr;
|
||||
}
|
||||
|
||||
|
||||
int SCH_SELECTION_TOOL::SelectNode( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
|
||||
|
||||
SelectPoint( cursorPos, nodeTypes );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCH_SELECTION_TOOL::SelectConnection( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
RequestSelection( (KICAD_T[]) { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT } );
|
||||
|
||||
if( m_selection.Empty() )
|
||||
return 0;
|
||||
|
||||
SCH_LINE* line = (SCH_LINE*) m_selection.GetItem( 0 );
|
||||
EDA_ITEMS items;
|
||||
|
||||
m_frame->GetScreen()->ClearDrawingState();
|
||||
m_frame->GetScreen()->MarkConnections( line );
|
||||
|
||||
for( SCH_ITEM* item = m_frame->GetScreen()->GetDrawItems(); item; item = item->Next() )
|
||||
{
|
||||
if( item->GetFlags() & CANDIDATE )
|
||||
select( item );
|
||||
|
||||
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCH_SELECTION_TOOL::AddItemsToSel( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
std::vector<SCH_ITEM*>* items = aEvent.Parameter<std::vector<SCH_ITEM*>*>();
|
||||
|
||||
|
@ -524,7 +552,7 @@ int SCH_SELECTION_TOOL::SelectItems( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int SCH_SELECTION_TOOL::SelectItem( const TOOL_EVENT& aEvent )
|
||||
int SCH_SELECTION_TOOL::AddItemToSel( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
// Check if there is an item to be selected
|
||||
SCH_ITEM* item = aEvent.Parameter<SCH_ITEM*>();
|
||||
|
@ -541,7 +569,7 @@ int SCH_SELECTION_TOOL::SelectItem( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int SCH_SELECTION_TOOL::UnselectItems( const TOOL_EVENT& aEvent )
|
||||
int SCH_SELECTION_TOOL::RemoveItemsFromSel( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
std::vector<SCH_ITEM*>* items = aEvent.Parameter<std::vector<SCH_ITEM*>*>();
|
||||
|
||||
|
@ -557,7 +585,7 @@ int SCH_SELECTION_TOOL::UnselectItems( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int SCH_SELECTION_TOOL::UnselectItem( const TOOL_EVENT& aEvent )
|
||||
int SCH_SELECTION_TOOL::RemoveItemFromSel( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
// Check if there is an item to be selected
|
||||
SCH_ITEM* item = aEvent.Parameter<SCH_ITEM*>();
|
||||
|
@ -914,13 +942,16 @@ bool SCH_SELECTION_TOOL::selectionContains( const VECTOR2I& aPoint ) const
|
|||
|
||||
void SCH_SELECTION_TOOL::setTransitions()
|
||||
{
|
||||
Go( &SCH_SELECTION_TOOL::Main, SCH_ACTIONS::selectionActivate.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::ClearSelection, SCH_ACTIONS::selectionClear.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::SelectItem, SCH_ACTIONS::selectItem.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::SelectItems, SCH_ACTIONS::selectItems.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::UnselectItem, SCH_ACTIONS::unselectItem.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::UnselectItems, SCH_ACTIONS::unselectItems.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::SelectionMenu, SCH_ACTIONS::selectionMenu.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::Main, SCH_ACTIONS::selectionActivate.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::SelectNode, SCH_ACTIONS::selectNode.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::SelectConnection, SCH_ACTIONS::selectConnection.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::ClearSelection, SCH_ACTIONS::clearSelection.MakeEvent() );
|
||||
|
||||
Go( &SCH_SELECTION_TOOL::AddItemToSel, SCH_ACTIONS::addItemToSel.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::AddItemsToSel, SCH_ACTIONS::addItemsToSel.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::RemoveItemFromSel, SCH_ACTIONS::removeItemFromSel.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::RemoveItemsFromSel, SCH_ACTIONS::removeItemsFromSel.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::SelectionMenu, SCH_ACTIONS::selectionMenu.MakeEvent() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -90,17 +90,20 @@ public:
|
|||
const KICAD_T* aFilterList = SCH_COLLECTOR::AllItems,
|
||||
bool* aSelectionCancelledFlag = NULL, bool aCheckLocked = false );
|
||||
|
||||
///> Item selection event handler.
|
||||
int SelectItem( const TOOL_EVENT& aEvent );
|
||||
int AddItemToSel( const TOOL_EVENT& aEvent );
|
||||
int AddItemsToSel( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> Multiple item selection event handler
|
||||
int SelectItems( const TOOL_EVENT& aEvent );
|
||||
int RemoveItemFromSel( const TOOL_EVENT& aEvent );
|
||||
int RemoveItemsFromSel( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> Item unselection event handler.
|
||||
int UnselectItem( const TOOL_EVENT& aEvent );
|
||||
///> Find (but don't select) node under cursor
|
||||
SCH_ITEM* GetNode( VECTOR2I aPosition );
|
||||
|
||||
///> Multiple item unselection event handler
|
||||
int UnselectItems( const TOOL_EVENT& aEvent );
|
||||
///> Select node under cursor
|
||||
int SelectNode( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> If node selected then expand to connection, otherwise select connection under cursor
|
||||
int SelectConnection( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> Clear current selection event handler.
|
||||
int ClearSelection( const TOOL_EVENT& aEvent );
|
||||
|
@ -115,16 +118,6 @@ public:
|
|||
int SelectionMenu( const TOOL_EVENT& aEvent );
|
||||
|
||||
private:
|
||||
/**
|
||||
* Function selectCursor()
|
||||
* Selects an item under the cursor unless there is something already selected or aForceSelect
|
||||
* is true.
|
||||
* @param aForceSelect forces to select an item even if there is an item already selected.
|
||||
* @param aClientFilter allows the client to perform tool- or action-specific filtering.
|
||||
* @return true if eventually there is an item selected, false otherwise.
|
||||
*/
|
||||
bool selectCursor( const KICAD_T aFilterList[], bool aForceSelect = false );
|
||||
|
||||
/**
|
||||
* Function selectMultiple()
|
||||
* Handles drawing a selection box that allows one to select many items at
|
||||
|
|
|
@ -274,7 +274,7 @@ public:
|
|||
* @param aScanTypes List of item types
|
||||
* @return true if the item type is contained in the list aScanTypes
|
||||
*/
|
||||
bool IsType( const KICAD_T aScanTypes[] )
|
||||
virtual bool IsType( const KICAD_T aScanTypes[] )
|
||||
{
|
||||
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
|
||||
{
|
||||
|
|
|
@ -129,6 +129,10 @@ enum KICAD_T
|
|||
SCH_FIELD_LOCATE_FOOTPRINT_T,
|
||||
SCH_FIELD_LOCATE_DATASHEET_T,
|
||||
|
||||
// Same for picking wires and busses from SCH_LINE_T items
|
||||
SCH_LINE_LOCATE_WIRE_T,
|
||||
SCH_LINE_LOCATE_BUS_T,
|
||||
|
||||
// General
|
||||
SCH_SCREEN_T,
|
||||
|
||||
|
|
|
@ -84,14 +84,6 @@ public:
|
|||
*/
|
||||
static SELECTION_CONDITION OnlyType( KICAD_T aType );
|
||||
|
||||
/**
|
||||
* Function OnlyTypes
|
||||
* Creates a functor that tests if the selected items are *only* of given types.
|
||||
* @param aTypes is a vector containing types that are searched.
|
||||
* @return Functor testing if selected items are exclusively of the requested types.
|
||||
*/
|
||||
static SELECTION_CONDITION OnlyTypes( const std::vector<KICAD_T>& aTypes );
|
||||
|
||||
/**
|
||||
* Function OnlyTypes
|
||||
* Creates a functor that tests if the selected items are *only* of given types.
|
||||
|
@ -136,8 +128,7 @@ private:
|
|||
static bool onlyTypeFunc( const SELECTION& aSelection, KICAD_T aType );
|
||||
|
||||
///> Helper function used by OnlyTypes()
|
||||
static bool onlyTypesFunc( const SELECTION& aSelection, const std::vector<KICAD_T>& aTypes );
|
||||
static bool onlyTypesFuncArr( const SELECTION& aSelection, const KICAD_T aTypes[] );
|
||||
static bool onlyTypesFunc( const SELECTION& aSelection, const KICAD_T aTypes[] );
|
||||
|
||||
///> Helper function used by Count()
|
||||
static bool countFunc( const SELECTION& aSelection, int aNumber );
|
||||
|
|
Loading…
Reference in New Issue