mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 11:01:41 +00:00
Implement SCH_SELECTION_TOOL (but still with legacy semantics).
This commit is contained in:
parent
e885d739a4
commit
1a007c3e4b
common/tool
eeschema
CMakeLists.txtautoplace_fields.cppcontrole.cppcross-probing.cpphotkeys.cpplib_collectors.honleftclick.cpponrightclick.cppsch_base_frame.hsch_collectors.cppsch_collectors.hsch_component.cppsch_component.hsch_edit_frame.cppsch_edit_frame.hsch_item_struct.hschedit.cpp
tools
gerbview
include
pcbnew
@ -139,3 +139,16 @@ TOOL_ACTION ACTIONS::gridResetOrigin( "common.Control.gridResetOrigin",
|
||||
TOOL_ACTION ACTIONS::gridPreset( "common.Control.gridPreset",
|
||||
AS_GLOBAL, 0,
|
||||
"", "" );
|
||||
|
||||
|
||||
// System-wide selection Events
|
||||
|
||||
///> Event sent after an item is selected.
|
||||
const TOOL_EVENT EVENTS::SelectedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.selected" );
|
||||
|
||||
///> Event sent after an item is unselected.
|
||||
const TOOL_EVENT EVENTS::UnselectedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.unselected" );
|
||||
|
||||
///> Event sent after selection is cleared.
|
||||
const TOOL_EVENT EVENTS::ClearedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.cleared" );
|
||||
|
||||
|
@ -164,7 +164,6 @@ set( EESCHEMA_SRCS
|
||||
generate_alias_info.cpp
|
||||
getpart.cpp
|
||||
hierarch.cpp
|
||||
tools/sch_editor_control.cpp
|
||||
hotkeys.cpp
|
||||
lib_arc.cpp
|
||||
lib_bezier.cpp
|
||||
@ -244,6 +243,8 @@ set( EESCHEMA_SRCS
|
||||
|
||||
tools/sch_actions.cpp
|
||||
tools/sch_drawing_tool.cpp
|
||||
tools/sch_edit_tool.cpp
|
||||
tools/sch_editor_control.cpp
|
||||
tools/sch_picker_tool.cpp
|
||||
tools/sch_selection_tool.cpp
|
||||
tools/selection.cpp
|
||||
|
@ -63,6 +63,8 @@
|
||||
#include <kiface_i.h>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/sch_selection_tool.h>
|
||||
|
||||
#define FIELD_PADDING 10 // arbitrarily chosen for aesthetics
|
||||
#define FIELD_PADDING_ALIGNED 18 // aligns 50 mil text to a 100 mil grid
|
||||
@ -683,8 +685,9 @@ const AUTOPLACER::SIDE AUTOPLACER::SIDE_RIGHT( 1, 0 );
|
||||
|
||||
void SCH_EDIT_FRAME::OnAutoplaceFields( wxCommandEvent& aEvent )
|
||||
{
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
|
||||
// Get the item under cursor if we're not currently moving something
|
||||
if( !item )
|
||||
@ -692,9 +695,8 @@ void SCH_EDIT_FRAME::OnAutoplaceFields( wxCommandEvent& aEvent )
|
||||
if( aEvent.GetInt() == 0 )
|
||||
return;
|
||||
|
||||
EDA_HOTKEY_CLIENT_DATA& data = dynamic_cast<EDA_HOTKEY_CLIENT_DATA&>(
|
||||
*aEvent.GetClientObject() );
|
||||
item = LocateItem( data.GetPosition(), SCH_COLLECTOR::MovableItems, aEvent.GetInt() );
|
||||
auto& data = dynamic_cast<EDA_HOTKEY_CLIENT_DATA&>( *aEvent.GetClientObject() );
|
||||
item = selTool->SelectPoint( data.GetPosition(), SCH_COLLECTOR::MovableItems );
|
||||
screen->SetCurItem( NULL );
|
||||
|
||||
if( !item || item->GetEditFlags() )
|
||||
|
@ -23,224 +23,16 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* eeschema/controle.cpp
|
||||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <eda_dde.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <menus_helpers.h>
|
||||
#include <msgpanel.h>
|
||||
#include <bitmaps.h>
|
||||
|
||||
#include <eeschema_id.h>
|
||||
#include <general.h>
|
||||
#include <hotkeys.h>
|
||||
#include <lib_edit_frame.h>
|
||||
#include <viewlib_frame.h>
|
||||
#include <lib_draw_item.h>
|
||||
#include <lib_pin.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <sch_marker.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_view.h>
|
||||
|
||||
|
||||
SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KICAD_T aFilterList[],
|
||||
int aHotKeyCommandId,
|
||||
bool* aClarificationMenuCancelled )
|
||||
{
|
||||
SCH_ITEM* item;
|
||||
LIB_PIN* Pin = NULL;
|
||||
SCH_COMPONENT* component = NULL;
|
||||
wxPoint gridPosition = GetNearestGridPosition( aPosition );
|
||||
|
||||
// Check the on grid position first. There is more likely to be multiple items on
|
||||
// grid than off grid.
|
||||
m_canvas->SetAbortRequest( false ); // be sure a old abort request in not pending
|
||||
item = LocateItem( gridPosition, aFilterList, aHotKeyCommandId );
|
||||
|
||||
// If the user aborted the clarification context menu, don't show it again at the
|
||||
// off grid position.
|
||||
if( !item && m_canvas->GetAbortRequest() )
|
||||
{
|
||||
if( aClarificationMenuCancelled )
|
||||
*aClarificationMenuCancelled = true;
|
||||
|
||||
m_canvas->SetAbortRequest( false );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( !item && (aPosition != gridPosition) )
|
||||
item = LocateItem( aPosition, aFilterList, aHotKeyCommandId );
|
||||
|
||||
if( !item )
|
||||
{
|
||||
if( aClarificationMenuCancelled )
|
||||
*aClarificationMenuCancelled = m_canvas->GetAbortRequest();
|
||||
|
||||
m_canvas->SetAbortRequest( false ); // Just in case the user aborted the context menu.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Cross probing to Pcbnew if a pin or a component is found
|
||||
switch( item->Type() )
|
||||
{
|
||||
case SCH_FIELD_T:
|
||||
case LIB_FIELD_T:
|
||||
component = (SCH_COMPONENT*) item->GetParent();
|
||||
SendMessageToPCBNEW( item, component );
|
||||
break;
|
||||
|
||||
case SCH_COMPONENT_T:
|
||||
component = (SCH_COMPONENT*) item;
|
||||
SendMessageToPCBNEW( item, component );
|
||||
break;
|
||||
|
||||
case LIB_PIN_T:
|
||||
Pin = (LIB_PIN*) item;
|
||||
component = (SCH_COMPONENT*) LocateItem( aPosition, SCH_COLLECTOR::ComponentsOnly );
|
||||
break;
|
||||
|
||||
/* case SCH_SHEET_T: */
|
||||
/* // This may lag on larger projects */
|
||||
/* SendMessageToPCBNEW( item, nullptr ); */
|
||||
/* break; */
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
if( Pin )
|
||||
{
|
||||
// Force display pin information (the previous display could be a component info)
|
||||
MSG_PANEL_ITEMS items;
|
||||
|
||||
Pin->GetMsgPanelInfo( m_UserUnits, items, component );
|
||||
|
||||
SetMsgPanel( items );
|
||||
|
||||
// Cross probing:2 - pin found, and send a locate pin command to Pcbnew (highlight net)
|
||||
SendMessageToPCBNEW( Pin, component );
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, const KICAD_T aFilterList[],
|
||||
int aHotKeyCommandId )
|
||||
{
|
||||
SCH_ITEM* item = NULL;
|
||||
|
||||
m_collectedItems.Collect( GetScreen()->GetDrawItems(), aFilterList, aPosition );
|
||||
|
||||
if( m_collectedItems.GetCount() == 0 )
|
||||
{
|
||||
ClearMsgPanel();
|
||||
}
|
||||
else if( m_collectedItems.GetCount() == 1 )
|
||||
{
|
||||
item = m_collectedItems[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
// There are certain parent/child and enclosure combinations that can be handled
|
||||
// automatically. Since schematics are meant to be human-readable we don't have
|
||||
// all the various overlap and coverage issues that we do in Pcbnew.
|
||||
if( m_collectedItems.GetCount() == 2 )
|
||||
{
|
||||
SCH_ITEM* a = m_collectedItems[ 0 ];
|
||||
SCH_ITEM* b = m_collectedItems[ 1 ];
|
||||
|
||||
if( a->GetParent() == b )
|
||||
item = a;
|
||||
else if( a == b->GetParent() )
|
||||
item = b;
|
||||
else if( a->Type() == SCH_SHEET_T && b->Type() != SCH_SHEET_T )
|
||||
item = b;
|
||||
else if( b->Type() == SCH_SHEET_T && a->Type() != SCH_SHEET_T )
|
||||
item = a;
|
||||
}
|
||||
|
||||
// There are certain combinations of items that do not need clarification such as
|
||||
// a corner were two lines meet or all the items form a junction.
|
||||
if( aHotKeyCommandId )
|
||||
{
|
||||
switch( aHotKeyCommandId )
|
||||
{
|
||||
case HK_DRAG:
|
||||
if( m_collectedItems.IsCorner() || m_collectedItems.IsNode( false )
|
||||
|| m_collectedItems.IsDraggableJunction() )
|
||||
{
|
||||
item = m_collectedItems[0];
|
||||
}
|
||||
break;
|
||||
|
||||
case HK_MOVE_COMPONENT_OR_ITEM:
|
||||
if( m_collectedItems.GetCount() == 2 &&
|
||||
dynamic_cast< SCH_SHEET_PIN * >( m_collectedItems[0] ) &&
|
||||
dynamic_cast< SCH_SHEET * >( m_collectedItems[1] ) )
|
||||
{
|
||||
item = m_collectedItems[0];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if( item == NULL )
|
||||
{
|
||||
wxASSERT_MSG( m_collectedItems.GetCount() <= MAX_SELECT_ITEM_IDS,
|
||||
wxT( "Select item clarification context menu size limit exceeded." ) );
|
||||
|
||||
wxMenu selectMenu;
|
||||
|
||||
AddMenuItem( &selectMenu, wxID_NONE, _( "Clarify Selection" ), KiBitmap( info_xpm ) );
|
||||
selectMenu.AppendSeparator();
|
||||
|
||||
for( int i = 0; i < m_collectedItems.GetCount() && i < MAX_SELECT_ITEM_IDS; i++ )
|
||||
{
|
||||
wxString text = m_collectedItems[i]->GetSelectMenuText( m_UserUnits );
|
||||
BITMAP_DEF xpm = m_collectedItems[i]->GetMenuImage();
|
||||
AddMenuItem( &selectMenu, ID_SELECT_ITEM_START + i, text, KiBitmap( xpm ) );
|
||||
}
|
||||
|
||||
// Set to NULL in case the user aborts the clarification context menu.
|
||||
GetScreen()->SetCurItem( NULL );
|
||||
m_canvas->SetAbortRequest( true ); // Changed to false if an item is selected
|
||||
PopupMenu( &selectMenu );
|
||||
|
||||
if( !m_canvas->GetAbortRequest() )
|
||||
{
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
item = GetScreen()->GetCurItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GetScreen()->SetCurItem( item );
|
||||
|
||||
if( item )
|
||||
{
|
||||
MSG_PANEL_ITEMS items;
|
||||
item->GetMsgPanelInfo( m_UserUnits, items );
|
||||
SetMsgPanel( items );
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearMsgPanel();
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
bool SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
|
||||
{
|
||||
// Filter out the 'fake' mouse motion after a keyboard movement
|
||||
|
@ -143,22 +143,29 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
|
||||
}
|
||||
|
||||
|
||||
std::string FormatProbeItem( EDA_ITEM* aItem, SCH_COMPONENT* aPart )
|
||||
std::string FormatProbeItem( EDA_ITEM* aItem, SCH_COMPONENT* aComp )
|
||||
{
|
||||
// This is a keyword followed by a quoted string.
|
||||
|
||||
// Cross probing to Pcbnew if a pin or a component is found
|
||||
switch( aItem->Type() )
|
||||
{
|
||||
case SCH_FIELD_T:
|
||||
case LIB_PIN_T:
|
||||
wxFAIL_MSG( "What are we doing with LIB_* items here?" );
|
||||
break;
|
||||
|
||||
case LIB_FIELD_T:
|
||||
if( aPart )
|
||||
return StrPrintf( "$PART: \"%s\"", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
|
||||
wxFAIL_MSG( "What are we doing with LIB_* items here?" );
|
||||
// fall through to SCH_FIELD_T:
|
||||
|
||||
case SCH_FIELD_T:
|
||||
if( aComp )
|
||||
return StrPrintf( "$PART: \"%s\"", TO_UTF8( aComp->GetField( REFERENCE )->GetText() ) );
|
||||
break;
|
||||
|
||||
case SCH_COMPONENT_T:
|
||||
aPart = (SCH_COMPONENT*) aItem;
|
||||
return StrPrintf( "$PART: \"%s\"", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
|
||||
aComp = (SCH_COMPONENT*) aItem;
|
||||
return StrPrintf( "$PART: \"%s\"", TO_UTF8( aComp->GetField( REFERENCE )->GetText() ) );
|
||||
|
||||
case SCH_SHEET_T:
|
||||
{
|
||||
@ -166,24 +173,23 @@ std::string FormatProbeItem( EDA_ITEM* aItem, SCH_COMPONENT* aPart )
|
||||
return StrPrintf( "$SHEET: \"%8.8lX\"", (unsigned long) sheet->GetTimeStamp() );
|
||||
}
|
||||
|
||||
case LIB_PIN_T:
|
||||
case SCH_PIN_T:
|
||||
{
|
||||
if( !aPart )
|
||||
break;
|
||||
|
||||
LIB_PIN* pin = (LIB_PIN*) aItem;
|
||||
SCH_PIN* pin = (SCH_PIN*) aItem;
|
||||
aComp = pin->GetParentComponent();
|
||||
|
||||
if( !pin->GetNumber().IsEmpty() )
|
||||
{
|
||||
return StrPrintf( "$PIN: \"%s\" $PART: \"%s\"", TO_UTF8( pin->GetNumber() ),
|
||||
TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
|
||||
return StrPrintf( "$PIN: \"%s\" $PART: \"%s\"",
|
||||
TO_UTF8( pin->GetNumber() ),
|
||||
TO_UTF8( aComp->GetField( REFERENCE )->GetText() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return StrPrintf( "$PART: \"%s\"", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
|
||||
return StrPrintf( "$PART: \"%s\"",
|
||||
TO_UTF8( aComp->GetField( REFERENCE )->GetText() ) );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include <sch_sheet.h>
|
||||
|
||||
#include <dialogs/dialog_schematic_find.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/sch_selection_tool.h>
|
||||
|
||||
// Remark: the hotkey message info is used as keyword in hotkey config files and
|
||||
// as comments in help windows, therefore translated only when displayed
|
||||
@ -610,7 +612,8 @@ bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||
|
||||
if( aItem == NULL )
|
||||
{
|
||||
aItem = LocateAndShowItem( aPosition, SCH_COLLECTOR::CopyableItems );
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
aItem = selTool->SelectPoint( aPosition, SCH_COLLECTOR::CopyableItems );
|
||||
|
||||
if( aItem == NULL )
|
||||
break;
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
* @param aIndex The index into the list.
|
||||
* @return LIB_ITEM* at \a aIndex or NULL.
|
||||
*/
|
||||
LIB_ITEM* operator[]( int aIndex ) const
|
||||
LIB_ITEM* operator[]( int aIndex ) const override
|
||||
{
|
||||
if( (unsigned)aIndex < (unsigned)GetCount() )
|
||||
return (LIB_ITEM*) m_List[ aIndex ];
|
||||
|
@ -34,10 +34,13 @@
|
||||
#include <sch_bitmap.h>
|
||||
#include <netlist_object.h>
|
||||
#include <sch_view.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/sch_selection_tool.h>
|
||||
|
||||
void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
|
||||
{
|
||||
SCH_ITEM* item = GetScreen()->GetCurItem();
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
|
||||
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
||||
{
|
||||
@ -76,7 +79,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
|
||||
}
|
||||
else
|
||||
{
|
||||
item = LocateAndShowItem( aPosition );
|
||||
item = selTool->SelectPoint( aPosition );
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +99,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
|
||||
SCH_COMPONENT_T,
|
||||
SCH_SHEET_PIN_T,
|
||||
EOT };
|
||||
item = LocateAndShowItem( aPosition, wiresAndComponents );
|
||||
item = selTool->SelectPoint( aPosition, wiresAndComponents );
|
||||
|
||||
if( !item )
|
||||
break;
|
||||
@ -121,7 +124,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
|
||||
case ID_SIM_TUNE:
|
||||
{
|
||||
constexpr KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T, EOT };
|
||||
item = LocateAndShowItem( aPosition, fieldsAndComponents );
|
||||
item = selTool->SelectPoint( aPosition, fieldsAndComponents );
|
||||
|
||||
if( !item )
|
||||
return;
|
||||
@ -159,13 +162,14 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
|
||||
void SCH_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition )
|
||||
|
||||
{
|
||||
EDA_ITEM* item = GetScreen()->GetCurItem();
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
EDA_ITEM* item = GetScreen()->GetCurItem();
|
||||
|
||||
switch( GetToolId() )
|
||||
{
|
||||
case ID_NO_TOOL_SELECTED:
|
||||
if( item == NULL || item->GetEditFlags() == 0 )
|
||||
item = LocateAndShowItem( aPosition, SCH_COLLECTOR::DoubleClickItems );
|
||||
item = selTool->SelectPoint( aPosition, SCH_COLLECTOR::DoubleClickItems );
|
||||
|
||||
if( item == NULL || item->GetEditFlags() != 0 )
|
||||
break;
|
||||
|
@ -54,7 +54,9 @@
|
||||
#include <sch_view.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/sch_actions.h>
|
||||
#include <tools/sch_selection_tool.h>
|
||||
|
||||
static void AddMenusForBlock( wxMenu* PopMenu, SCH_EDIT_FRAME* frame );
|
||||
static void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame );
|
||||
@ -77,9 +79,10 @@ static void AddMenusForBusEntry( wxMenu* aPopMenu, SCH_BUS_ENTRY_BASE * aBusEntr
|
||||
|
||||
bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
||||
{
|
||||
SCH_ITEM* item = GetScreen()->GetCurItem();
|
||||
bool blockActive = GetScreen()->IsBlockActive();
|
||||
wxString msg;
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
SCH_ITEM* item = GetScreen()->GetCurItem();
|
||||
bool blockActive = GetScreen()->IsBlockActive();
|
||||
wxString msg;
|
||||
|
||||
// Ugly hack, clear any highligthed symbol, because the HIGHLIGHT flag create issues when creating menus
|
||||
// Will be fixed later
|
||||
@ -147,7 +150,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
||||
if( item == NULL || item->GetEditFlags() == 0 )
|
||||
{
|
||||
bool actionCancelled = false;
|
||||
item = LocateAndShowItem( aPosition, SCH_COLLECTOR::AllItemsButPins, 0, &actionCancelled );
|
||||
item = selTool->SelectPoint( aPosition, SCH_COLLECTOR::AllItemsButPins, &actionCancelled );
|
||||
|
||||
// If the clarify item selection context menu is aborted, don't show the context menu.
|
||||
if( item == NULL && actionCancelled )
|
||||
@ -744,8 +747,9 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame )
|
||||
|
||||
void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame )
|
||||
{
|
||||
wxPoint pos = frame->GetCrossHairPosition();
|
||||
wxString msg;
|
||||
SCH_SELECTION_TOOL* selTool = frame->GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
wxPoint pos = frame->GetCrossHairPosition();
|
||||
wxString msg;
|
||||
|
||||
if( Bus == NULL )
|
||||
{
|
||||
@ -773,8 +777,8 @@ void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame )
|
||||
|
||||
// Have to pick up the pointer again because it may have been changed by SchematicCleanUp
|
||||
bool actionCancelled = false;
|
||||
Bus = dynamic_cast<SCH_LINE*>( frame->LocateAndShowItem( pos, SCH_COLLECTOR::AllItemsButPins,
|
||||
0, &actionCancelled ) );
|
||||
Bus = dynamic_cast<SCH_LINE*>( selTool->SelectPoint( pos, SCH_COLLECTOR::AllItemsButPins,
|
||||
&actionCancelled ) );
|
||||
wxASSERT( Bus );
|
||||
}
|
||||
|
||||
|
@ -110,6 +110,11 @@ public:
|
||||
|
||||
KIGFX::SCH_RENDER_SETTINGS* GetRenderSettings();
|
||||
|
||||
/**
|
||||
* Allow some frames to show/hide hidden pins. The default impl shows all pins.
|
||||
*/
|
||||
virtual bool GetShowAllPins() const { return true; }
|
||||
|
||||
/**
|
||||
* switches currently used canvas ( Cairo / OpenGL).
|
||||
*/
|
||||
|
@ -51,7 +51,7 @@ const KICAD_T SCH_COLLECTOR::AllItems[] = {
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_FIELD_T,
|
||||
SCH_COMPONENT_T,
|
||||
LIB_PIN_T,
|
||||
SCH_PIN_T,
|
||||
SCH_SHEET_PIN_T,
|
||||
SCH_SHEET_T,
|
||||
EOT
|
||||
@ -238,43 +238,21 @@ const KICAD_T SCH_COLLECTOR::DoubleClickItems[] = {
|
||||
|
||||
SEARCH_RESULT SCH_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
|
||||
{
|
||||
if( aItem->Type() != LIB_PIN_T && !aItem->HitTest( m_RefPos ) )
|
||||
return SEARCH_CONTINUE;
|
||||
|
||||
// Pins have special hit testing requirements that are relative to their parent
|
||||
// SCH_COMPONENT item.
|
||||
if( aItem->Type() == LIB_PIN_T )
|
||||
{
|
||||
wxCHECK_MSG( aTestData && ( (EDA_ITEM*) aTestData )->Type() == SCH_COMPONENT_T,
|
||||
SEARCH_CONTINUE, wxT( "Cannot inspect invalid data. Bad programmer!" ) );
|
||||
|
||||
// Pin hit testing is relative to the components position and orientation in the
|
||||
// schematic. The hit test position must be converted to library coordinates.
|
||||
SCH_COMPONENT* component = (SCH_COMPONENT*) aTestData;
|
||||
TRANSFORM transform = component->GetTransform().InverseTransform();
|
||||
wxPoint position = transform.TransformCoordinate( m_RefPos - component->GetPosition() );
|
||||
|
||||
position.y *= -1; // Y axis polarity in schematic is inverted from library.
|
||||
|
||||
if( !aItem->HitTest( position ) )
|
||||
return SEARCH_CONTINUE;
|
||||
}
|
||||
|
||||
Append( aItem );
|
||||
if( aItem->HitTest( m_RefPos ) )
|
||||
Append( aItem );
|
||||
|
||||
return SEARCH_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
void SCH_COLLECTOR::Collect( SCH_ITEM* aItem, const KICAD_T aFilterList[],
|
||||
const wxPoint& aPosition )
|
||||
void SCH_COLLECTOR::Collect( SCH_ITEM* aItem, const KICAD_T aFilterList[], const wxPoint& aPos )
|
||||
{
|
||||
Empty(); // empty the collection just in case
|
||||
|
||||
SetScanTypes( aFilterList );
|
||||
|
||||
// remember where the snapshot was taken from and pass refPos to the Inspect() function.
|
||||
SetRefPos( aPosition );
|
||||
SetRefPos( aPos );
|
||||
|
||||
EDA_ITEM::IterateForward( aItem, m_inspector, NULL, m_ScanTypes );
|
||||
}
|
||||
@ -319,7 +297,7 @@ bool SCH_COLLECTOR::IsNode( bool aIncludePins ) const
|
||||
continue;
|
||||
}
|
||||
|
||||
if( type == LIB_PIN_T )
|
||||
if( type == SCH_PIN_T )
|
||||
{
|
||||
if( !aIncludePins )
|
||||
return false;
|
||||
@ -559,7 +537,7 @@ SEARCH_RESULT SCH_FIND_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
|
||||
|
||||
if( aItem->Matches( m_findReplaceData, m_currentSheetPath, &position ) )
|
||||
{
|
||||
if( aItem->Type() == LIB_PIN_T )
|
||||
if( aItem->Type() == SCH_PIN_T )
|
||||
{
|
||||
wxCHECK_MSG( aTestData && ( (EDA_ITEM*) aTestData )->Type() == SCH_COMPONENT_T,
|
||||
SEARCH_CONTINUE, wxT( "Cannot inspect invalid data. Bad programmer!" ) );
|
||||
|
@ -142,7 +142,7 @@ public:
|
||||
* @param aIndex The index into the list.
|
||||
* @return SCH_ITEM* at \a aIndex or NULL.
|
||||
*/
|
||||
SCH_ITEM* operator[]( int aIndex ) const
|
||||
SCH_ITEM* operator[]( int aIndex ) const override
|
||||
{
|
||||
if( (unsigned)aIndex < (unsigned)GetCount() )
|
||||
return (SCH_ITEM*) m_List[ aIndex ];
|
||||
@ -159,9 +159,9 @@ public:
|
||||
* @param aFilterList A list of #KICAD_T types with a terminating #EOT, that determines
|
||||
* what is to be collected and the priority order of the resulting
|
||||
* collection.
|
||||
* @param aPosition A wxPoint to use in hit-testing.
|
||||
* @param aPos A wxPoint to use in hit-testing.
|
||||
*/
|
||||
void Collect( SCH_ITEM* aItem, const KICAD_T aFilterList[], const wxPoint& aPosition );
|
||||
void Collect( SCH_ITEM* aItem, const KICAD_T aFilterList[], const wxPoint& aPos );
|
||||
|
||||
/**
|
||||
* Function IsCorner
|
||||
@ -289,7 +289,7 @@ public:
|
||||
}
|
||||
|
||||
SCH_ITEM* GetItem( int ndx ) const;
|
||||
SCH_ITEM* operator[]( int ndx ) const;
|
||||
SCH_ITEM* operator[]( int ndx ) const override;
|
||||
|
||||
void SetForceSearch( bool doSearch = true ) { m_forceSearch = doSearch; }
|
||||
|
||||
@ -405,8 +405,7 @@ class SCH_TYPE_COLLECTOR : public SCH_COLLECTOR
|
||||
public:
|
||||
/**
|
||||
* Function Inspect
|
||||
* is the examining function within the INSPECTOR which is passed to the
|
||||
* Iterate function.
|
||||
* is the examining function within the INSPECTOR which is passed to the Iterate function.
|
||||
*
|
||||
* @param testItem An EDA_ITEM to examine.
|
||||
* @param testData is not used in this class.
|
||||
@ -417,12 +416,11 @@ public:
|
||||
|
||||
/**
|
||||
* Function Collect
|
||||
* scans a BOARD_ITEM using this class's Inspector method, which does
|
||||
* the collection.
|
||||
* @param aBoard The BOARD_ITEM to scan.
|
||||
* scans a DLIST using this class's Inspector method, which does the collection.
|
||||
* @param aItem The head of a DLIST to scan.
|
||||
* @param aScanList The KICAD_Ts to gather up.
|
||||
*/
|
||||
void Collect( SCH_ITEM* aBoard, const KICAD_T aScanList[] );
|
||||
void Collect( SCH_ITEM* aItem, const KICAD_T aScanList[] );
|
||||
};
|
||||
|
||||
|
||||
|
@ -1612,18 +1612,11 @@ SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR aInspector, void* aTestData,
|
||||
return SEARCH_QUIT;
|
||||
break;
|
||||
|
||||
case LIB_PIN_T:
|
||||
if( PART_SPTR part = m_part.lock() )
|
||||
case SCH_PIN_T:
|
||||
for( SCH_PIN& pin : m_pins )
|
||||
{
|
||||
LIB_PINS pins;
|
||||
|
||||
part->GetPins( pins, m_unit, m_convert );
|
||||
|
||||
for( size_t i = 0; i < pins.size(); i++ )
|
||||
{
|
||||
if( SEARCH_QUIT == aInspector( pins[ i ], (void*) this ) )
|
||||
return SEARCH_QUIT;
|
||||
}
|
||||
if( SEARCH_QUIT == aInspector( &pin, (void*) this ) )
|
||||
return SEARCH_QUIT;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1728,7 +1721,7 @@ bool SCH_COMPONENT::operator!=( const SCH_COMPONENT& aComponent ) const
|
||||
}
|
||||
|
||||
|
||||
SCH_ITEM& SCH_COMPONENT::operator=( const SCH_ITEM& aItem )
|
||||
SCH_COMPONENT& SCH_COMPONENT::operator=( const SCH_ITEM& aItem )
|
||||
{
|
||||
wxCHECK_MSG( Type() == aItem.Type(), *this,
|
||||
wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
|
||||
|
@ -606,7 +606,7 @@ public:
|
||||
bool operator==( const SCH_COMPONENT& aComponent) const;
|
||||
bool operator!=( const SCH_COMPONENT& aComponent) const;
|
||||
|
||||
SCH_ITEM& operator=( const SCH_ITEM& aItem );
|
||||
SCH_COMPONENT& operator=( const SCH_ITEM& aItem );
|
||||
|
||||
bool IsReplaceable() const override { return true; }
|
||||
|
||||
|
@ -62,6 +62,7 @@
|
||||
#include <view/view.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/sch_actions.h>
|
||||
#include <tools/sch_selection_tool.h>
|
||||
|
||||
#include <wx/display.h>
|
||||
#include <build_version.h>
|
||||
@ -1107,7 +1108,8 @@ void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
|
||||
|
||||
void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
|
||||
{
|
||||
SCH_COMPONENT* component = NULL;
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
SCH_COMPONENT* component = NULL;
|
||||
|
||||
if( event.GetId() == ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP )
|
||||
{
|
||||
@ -1127,7 +1129,7 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
|
||||
|
||||
// Set the locat filter, according to the edit command
|
||||
const KICAD_T* filterList = SCH_COLLECTOR::ComponentsOnly;
|
||||
item = LocateAndShowItem( data->GetPosition(), filterList, event.GetInt() );
|
||||
item = selTool->SelectPoint( data->GetPosition(), filterList );
|
||||
|
||||
// Exit if no item found at the current location or the item is already being edited.
|
||||
if( item == NULL || item->GetEditFlags() != 0 )
|
||||
|
@ -225,7 +225,7 @@ public:
|
||||
bool GetForceHVLines() const { return m_forceHVLines; }
|
||||
void SetForceHVLines( bool aForceHVdirection ) { m_forceHVLines = aForceHVdirection; }
|
||||
|
||||
bool GetShowAllPins() const { return m_showAllPins; }
|
||||
bool GetShowAllPins() const override { return m_showAllPins; }
|
||||
void SetShowAllPins( bool aEnable ) { m_showAllPins = aEnable; }
|
||||
|
||||
bool GetShowFootprintPreviews() const { return m_footprintPreview; }
|
||||
@ -383,48 +383,6 @@ public:
|
||||
*/
|
||||
void AddItemToScreen( SCH_ITEM* aItem );
|
||||
|
||||
/**
|
||||
* Check the schematic at \a aPosition in logical (drawing) units for a item
|
||||
* matching the types in \a aFilterList.
|
||||
* <p>
|
||||
* The search is first performed at the nearest grid position to \a aPosition. If no
|
||||
* item if found on grid, then \a aPosition is tested for any items. If the item found
|
||||
* can be cross probed, a message is send to Pcbnew and the selected item is highlighted
|
||||
* in PCB editor.
|
||||
* </p>
|
||||
*
|
||||
* @param aPosition The wxPoint on the schematic to search.
|
||||
* @param aFilterList A list of #KICAD_T types to to filter.
|
||||
* @param aHotKeyCommandId A hot key command ID for performing additional tests when
|
||||
* multiple items are found at \a aPosition.
|
||||
* @param aClarifySelectionMenuCancelled is a pointer to a bool to handle a cancel command
|
||||
* from user when the user cancels the locate menu disambiguation (selection between located items)
|
||||
* @return A SCH_ITEM pointer of the item found or NULL if no item found
|
||||
*/
|
||||
SCH_ITEM* LocateAndShowItem( const wxPoint& aPosition,
|
||||
const KICAD_T aFilterList[] = SCH_COLLECTOR::AllItems,
|
||||
int aHotKeyCommandId = 0,
|
||||
bool* aClarifySelectionMenuCancelled = nullptr );
|
||||
|
||||
/**
|
||||
* Check for items at \a aPosition matching the types in \a aFilterList.
|
||||
* <p>
|
||||
* If multiple items are located at \a aPosition, a context menu is displayed to clarify
|
||||
* which item the user intended to select. If the user aborts the context menu, NULL is
|
||||
* returned and the abort request flag will be set to true. Make sure to clear this flag
|
||||
* before attempting to display any other context menus.
|
||||
* </p>
|
||||
*
|
||||
* @param aPosition The wxPoint location where to search.
|
||||
* @param aFilterList A list of #KICAD_T types to to filter.
|
||||
* @param aHotKeyCommandId A hot key command ID for performing additional tests when
|
||||
* multiple items are found at \a aPosition.
|
||||
* @return The SCH_ITEM pointer of the item found or NULL if no item found.
|
||||
*/
|
||||
SCH_ITEM* LocateItem( const wxPoint& aPosition,
|
||||
const KICAD_T aFilterList[] = SCH_COLLECTOR::AllItems,
|
||||
int aHotKeyCommandId = 0 );
|
||||
|
||||
/**
|
||||
* Delete the item found under the cross hair. If multiple items are found at the
|
||||
* cross hair position, a context menu is displayed to clarify which item to delete.
|
||||
|
@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2004-2019 KiCad Developers, see change_log.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
|
||||
@ -171,6 +171,17 @@ public:
|
||||
wxPoint& GetStoredPos() { return m_storedPos; }
|
||||
void SetStoredPos( wxPoint aPos ) { m_storedPos = aPos; }
|
||||
|
||||
/**
|
||||
* Function IsLocked
|
||||
* @return bool - true if the object is locked, else false
|
||||
*/
|
||||
virtual bool IsLocked() const { return false; }
|
||||
|
||||
/**
|
||||
* Function SetLocked
|
||||
* modifies 'lock' status for of the item.
|
||||
*/
|
||||
virtual void SetLocked( bool aLocked ) {}
|
||||
|
||||
/**
|
||||
* Function GetLayer
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include <simulation_cursors.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/sch_actions.h>
|
||||
#include <tools/sch_selection_tool.h>
|
||||
|
||||
void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||
{
|
||||
@ -364,8 +365,9 @@ void SCH_EDIT_FRAME::OnDuplicateItem( wxCommandEvent& event )
|
||||
|
||||
void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
|
||||
{
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
|
||||
// trying to move an item when there is a block at the same time is not acceptable
|
||||
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
||||
@ -381,8 +383,7 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
|
||||
|
||||
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
|
||||
|
||||
item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::MovableItems,
|
||||
aEvent.GetInt() );
|
||||
item = selTool->SelectPoint( data->GetPosition(), SCH_COLLECTOR::MovableItems );
|
||||
|
||||
// Exit if no item found at the current location or the item is already being edited.
|
||||
if( item == NULL || item->GetEditFlags() != 0 )
|
||||
@ -526,8 +527,10 @@ void SCH_EDIT_FRAME::DeleteConnection( bool aFullConnection )
|
||||
|
||||
bool SCH_EDIT_FRAME::DeleteItemAtCrossHair()
|
||||
{
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = LocateItem( GetCrossHairPosition(), SCH_COLLECTOR::ParentItems );
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
|
||||
SCH_ITEM* item = selTool->SelectPoint( GetCrossHairPosition(), SCH_COLLECTOR::ParentItems );
|
||||
|
||||
if( item )
|
||||
{
|
||||
@ -693,12 +696,13 @@ void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem )
|
||||
|
||||
void SCH_EDIT_FRAME::SelectAllFromSheet( wxCommandEvent& aEvent )
|
||||
{
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
|
||||
if( item != NULL )
|
||||
{
|
||||
item = LocateAndShowItem( item->GetPosition() );
|
||||
item = selTool->SelectPoint( item->GetPosition() );
|
||||
SendMessageToPCBNEW( item, NULL );
|
||||
}
|
||||
else
|
||||
@ -711,7 +715,7 @@ void SCH_EDIT_FRAME::SelectAllFromSheet( wxCommandEvent& aEvent )
|
||||
|
||||
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
|
||||
|
||||
item = LocateAndShowItem( data->GetPosition() );
|
||||
item = selTool->SelectPoint( data->GetPosition() );
|
||||
SendMessageToPCBNEW( item, NULL );
|
||||
}
|
||||
}
|
||||
@ -719,9 +723,10 @@ void SCH_EDIT_FRAME::SelectAllFromSheet( wxCommandEvent& aEvent )
|
||||
|
||||
void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
|
||||
{
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
BLOCK_SELECTOR& block = screen->m_BlockLocate;
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
BLOCK_SELECTOR& block = screen->m_BlockLocate;
|
||||
|
||||
// Allows block rotate operation on hot key.
|
||||
if( block.GetState() != STATE_NO_BLOCK )
|
||||
@ -752,8 +757,7 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
|
||||
|
||||
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
|
||||
|
||||
item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::RotatableItems,
|
||||
aEvent.GetInt() );
|
||||
item = selTool->SelectPoint( data->GetPosition(), SCH_COLLECTOR::RotatableItems );
|
||||
|
||||
// Exit if no item found at the current location or the item is already being edited.
|
||||
if( item == NULL || item->GetEditFlags() != 0 )
|
||||
@ -852,8 +856,9 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
|
||||
|
||||
void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
|
||||
{
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
|
||||
if( item == NULL )
|
||||
{
|
||||
@ -894,11 +899,11 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
|
||||
break;
|
||||
}
|
||||
|
||||
item = LocateAndShowItem( data->GetPosition(), filterList, aEvent.GetInt() );
|
||||
item = selTool->SelectPoint( data->GetPosition(), filterList );
|
||||
|
||||
// If no item found, and if an auxiliary filter exists, try to use it
|
||||
if( !item && filterListAux )
|
||||
item = LocateAndShowItem( data->GetPosition(), filterListAux, aEvent.GetInt() );
|
||||
item = selTool->SelectPoint( data->GetPosition(), filterListAux );
|
||||
|
||||
// Exit if no item found at the current location or the item is already being edited.
|
||||
if( item == NULL || item->GetEditFlags() != 0 )
|
||||
@ -1014,8 +1019,9 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
|
||||
|
||||
void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
|
||||
{
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
|
||||
// The easiest way to handle a menu or a hot key drag command
|
||||
// is to simulate a block drag command
|
||||
@ -1036,8 +1042,7 @@ void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
|
||||
|
||||
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
|
||||
|
||||
item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::DraggableItems,
|
||||
aEvent.GetInt() );
|
||||
item = selTool->SelectPoint( data->GetPosition(), SCH_COLLECTOR::DraggableItems );
|
||||
|
||||
// Exit if no item found at the current location or the item is already being edited.
|
||||
if( item == NULL || item->GetEditFlags() != 0 )
|
||||
@ -1086,9 +1091,10 @@ void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
|
||||
|
||||
void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
|
||||
{
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
BLOCK_SELECTOR& block = screen->m_BlockLocate;
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
BLOCK_SELECTOR& block = screen->m_BlockLocate;
|
||||
|
||||
// Allows block rotate operation on hot key.
|
||||
if( block.GetState() != STATE_NO_BLOCK )
|
||||
@ -1149,8 +1155,7 @@ void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
|
||||
|
||||
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
|
||||
|
||||
item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::OrientableItems,
|
||||
aEvent.GetInt() );
|
||||
item = selTool->SelectPoint( data->GetPosition(), SCH_COLLECTOR::OrientableItems );
|
||||
|
||||
// Exit if no item found at the current location or the item is already being edited.
|
||||
if( item == NULL || item->GetEditFlags() != 0 )
|
||||
@ -1231,8 +1236,9 @@ void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
|
||||
|
||||
void SCH_EDIT_FRAME::OnUnfoldBusHotkey( wxCommandEvent& aEvent )
|
||||
{
|
||||
auto data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
|
||||
auto item = GetScreen()->GetCurItem();
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
|
||||
SCH_ITEM* item = GetScreen()->GetCurItem();
|
||||
|
||||
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
|
||||
|
||||
@ -1242,8 +1248,7 @@ void SCH_EDIT_FRAME::OnUnfoldBusHotkey( wxCommandEvent& aEvent )
|
||||
if( aEvent.GetInt() == 0 )
|
||||
return;
|
||||
|
||||
item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::EditableItems,
|
||||
aEvent.GetInt() );
|
||||
item = selTool->SelectPoint( data->GetPosition(), SCH_COLLECTOR::EditableItems );
|
||||
|
||||
// Exit if no item found at the current location or the item is already being edited.
|
||||
if( item == NULL || item->GetEditFlags() != 0 )
|
||||
|
@ -28,8 +28,8 @@
|
||||
#include <tools/sch_editor_control.h>
|
||||
#include <tools/sch_picker_tool.h>
|
||||
#include <tools/sch_drawing_tool.h>
|
||||
|
||||
#include <sch_actions.h>
|
||||
#include <tools/sch_selection_tool.h>
|
||||
#include <tools/sch_actions.h>
|
||||
#include <tool/zoom_tool.h>
|
||||
|
||||
OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
||||
@ -180,6 +180,7 @@ void SCH_ACTIONS::RegisterAllTools( TOOL_MANAGER* aToolManager )
|
||||
{
|
||||
aToolManager->RegisterTool( new COMMON_TOOLS );
|
||||
aToolManager->RegisterTool( new ZOOM_TOOL );
|
||||
aToolManager->RegisterTool( new SCH_SELECTION_TOOL );
|
||||
aToolManager->RegisterTool( new SCH_EDITOR_CONTROL );
|
||||
aToolManager->RegisterTool( new SCH_PICKER_TOOL );
|
||||
aToolManager->RegisterTool( new SCH_DRAWING_TOOL );
|
||||
|
@ -112,6 +112,10 @@ public:
|
||||
static TOOL_ACTION finishDrawing;
|
||||
|
||||
// Editing
|
||||
static TOOL_ACTION editActivate;
|
||||
static TOOL_ACTION move;
|
||||
static TOOL_ACTION duplicate;
|
||||
static TOOL_ACTION rotate;
|
||||
static TOOL_ACTION properties;
|
||||
static TOOL_ACTION addJunction;
|
||||
static TOOL_ACTION addLabel;
|
||||
@ -131,6 +135,7 @@ public:
|
||||
|
||||
// Net highlighting
|
||||
static TOOL_ACTION highlightNet;
|
||||
static TOOL_ACTION clearHighlight;
|
||||
static TOOL_ACTION highlightNetSelection;
|
||||
static TOOL_ACTION highlightNetCursor;
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include "sch_drawing_tool.h"
|
||||
#include "sch_selection_tool.h"
|
||||
#include <sch_actions.h>
|
||||
|
||||
#include <sch_edit_frame.h>
|
||||
@ -513,6 +514,7 @@ int SCH_DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent )
|
||||
|
||||
int SCH_DRAWING_TOOL::doTwoClickPlace( KICAD_T aType )
|
||||
{
|
||||
SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
|
||||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
||||
SCH_ITEM* item = nullptr;
|
||||
|
||||
@ -569,8 +571,7 @@ int SCH_DRAWING_TOOL::doTwoClickPlace( KICAD_T aType )
|
||||
item = m_frame->CreateNewImage();
|
||||
break;
|
||||
case SCH_SHEET_PIN_T:
|
||||
item = m_frame->LocateAndShowItem( (wxPoint)cursorPos,
|
||||
SCH_COLLECTOR::SheetsAndSheetLabels );
|
||||
item = selTool->SelectPoint( cursorPos, SCH_COLLECTOR::SheetsAndSheetLabels );
|
||||
if( item )
|
||||
{
|
||||
if( m_frame->GetToolId() == ID_IMPORT_HLABEL_BUTT )
|
||||
|
50
eeschema/tools/sch_edit_tool.cpp
Normal file
50
eeschema/tools/sch_edit_tool.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 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
|
||||
*/
|
||||
|
||||
#include "sch_edit_tool.h"
|
||||
#include <sch_actions.h>
|
||||
#include <hotkeys.h>
|
||||
#include <bitmaps.h>
|
||||
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::editActivate( "eeschema.InteractiveEdit",
|
||||
AS_GLOBAL, 0,
|
||||
_( "Edit Activate" ), "", move_xpm, AF_ACTIVATE );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::move( "eeschema.InteractiveEdit.move",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MOVE_COMPONENT_OR_ITEM ),
|
||||
_( "Move" ), _( "Moves the selected item(s)" ), move_xpm, AF_ACTIVATE );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::duplicate( "eeschema.InteractiveEdit.duplicate",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DUPLICATE_ITEM ),
|
||||
_( "Duplicate" ), _( "Duplicates the selected item(s)" ), duplicate_xpm );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::rotate( "eeschema.InteractiveEdit.rotate",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROTATE ),
|
||||
_( "Rotate" ), _( "Rotates selected item(s)" ),
|
||||
rotate_ccw_xpm, AF_NONE );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::properties( "eeschema.InteractiveEdit.properties",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT ),
|
||||
_( "Properties..." ), _( "Displays item properties dialog" ), config_xpm );
|
||||
|
34
eeschema/tools/sch_edit_tool.h
Normal file
34
eeschema/tools/sch_edit_tool.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 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
|
||||
*/
|
||||
|
||||
#ifndef KICAD_SCH_EDIT_TOOL_H
|
||||
#define KICAD_SCH_EDIT_TOOL_H
|
||||
|
||||
#include <tool/tool_interactive.h>
|
||||
|
||||
|
||||
class SCH_EDIT_TOOL : public TOOL_INTERACTIVE
|
||||
{
|
||||
};
|
||||
|
||||
#endif //KICAD_SCH_EDIT_TOOL_H
|
@ -34,8 +34,9 @@
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/sch_actions.h>
|
||||
#include <tools/sch_picker_tool.h>
|
||||
#include <project.h>
|
||||
#include <tools/sch_editor_control.h>
|
||||
#include <tools/sch_selection_tool.h>
|
||||
#include <project.h>
|
||||
#include <hotkeys.h>
|
||||
#include <advanced_config.h>
|
||||
|
||||
@ -45,6 +46,9 @@ TOOL_ACTION SCH_ACTIONS::refreshPreview( "eeschema.EditorControl.refreshPreview"
|
||||
TOOL_ACTION SCH_ACTIONS::highlightNet( "eeschema.EditorControl.highlightNet",
|
||||
AS_GLOBAL, 0, "", "" );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::clearHighlight( "eeschema.EditorControl.clearHighlight",
|
||||
AS_GLOBAL, 0, "", "" );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::highlightNetSelection( "eeschema.EditorControl.highlightNetSelection",
|
||||
AS_GLOBAL, 0, "", "" );
|
||||
|
||||
@ -115,6 +119,59 @@ bool SCH_EDITOR_CONTROL::Init()
|
||||
}
|
||||
|
||||
|
||||
int SCH_EDITOR_CONTROL::CrossProbeSchToPcb( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
// Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
|
||||
if( m_probingSchToPcb )
|
||||
{
|
||||
m_probingSchToPcb = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
|
||||
const SELECTION& selection = selTool->GetSelection();
|
||||
|
||||
if( selection.Size() == 1 )
|
||||
{
|
||||
SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
|
||||
SCH_COMPONENT* component;
|
||||
|
||||
switch( item->Type() )
|
||||
{
|
||||
case SCH_FIELD_T:
|
||||
case LIB_FIELD_T:
|
||||
component = (SCH_COMPONENT*) item->GetParent();
|
||||
m_frame->SendMessageToPCBNEW( item, component );
|
||||
break;
|
||||
|
||||
case SCH_COMPONENT_T:
|
||||
component = (SCH_COMPONENT*) item;
|
||||
m_frame->SendMessageToPCBNEW( item, component );
|
||||
break;
|
||||
|
||||
case SCH_PIN_T:
|
||||
component = (SCH_COMPONENT*) item->GetParent();
|
||||
m_frame->SendMessageToPCBNEW( static_cast<SCH_PIN*>( item ), component );
|
||||
break;
|
||||
|
||||
#if 0 // This is too slow on larger projects
|
||||
case SCH_SHEET_T:
|
||||
SendMessageToPCBNEW( item, nullptr );
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// A magic cookie token 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 )
|
||||
{
|
||||
@ -123,7 +180,7 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
|
||||
EDA_ITEMS nodeList;
|
||||
bool retVal = true;
|
||||
|
||||
if( editFrame->GetScreen()->GetNode( wxPoint( aPosition.x, aPosition.y ), nodeList ) )
|
||||
if( aPosition != CLEAR && editFrame->GetScreen()->GetNode( (wxPoint) aPosition, nodeList ) )
|
||||
{
|
||||
if( TestDuplicateSheetNames( false ) > 0 )
|
||||
{
|
||||
@ -156,7 +213,7 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
|
||||
int SCH_EDITOR_CONTROL::HighlightNet( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||
VECTOR2I gridPosition = controls->GetCursorPosition( true );
|
||||
VECTOR2D gridPosition = controls->GetCursorPosition( true );
|
||||
|
||||
highlightNet( m_toolMgr, gridPosition );
|
||||
|
||||
@ -164,6 +221,14 @@ int SCH_EDITOR_CONTROL::HighlightNet( const TOOL_EVENT& aEvent )
|
||||
}
|
||||
|
||||
|
||||
int SCH_EDITOR_CONTROL::ClearHighlight( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
highlightNet( m_toolMgr, CLEAR );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCH_EDITOR_CONTROL::HighlightNetSelection( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SCH_SCREEN* screen = g_CurrentSheet->LastScreen();
|
||||
@ -269,14 +334,15 @@ void SCH_EDITOR_CONTROL::setTransitions()
|
||||
Go( &SCH_EDITOR_CONTROL::UnlockSelected, SCH_ACTIONS::unlock.MakeEvent() );
|
||||
*/
|
||||
|
||||
Go( &SCH_EDITOR_CONTROL::CrossProbeSchToPcb, EVENTS::SelectedEvent );
|
||||
Go( &SCH_EDITOR_CONTROL::CrossProbeSchToPcb, EVENTS::UnselectedEvent );
|
||||
Go( &SCH_EDITOR_CONTROL::CrossProbeSchToPcb, EVENTS::ClearedEvent );
|
||||
/*
|
||||
Go( &SCH_EDITOR_CONTROL::CrossProbeSchToPcb, SELECTION_TOOL::SelectedEvent );
|
||||
Go( &SCH_EDITOR_CONTROL::CrossProbeSchToPcb, SELECTION_TOOL::UnselectedEvent );
|
||||
Go( &SCH_EDITOR_CONTROL::CrossProbeSchToPcb, SELECTION_TOOL::ClearedEvent );
|
||||
Go( &SCH_EDITOR_CONTROL::CrossProbePcbToSch, SCH_ACTIONS::crossProbeSchToPcb.MakeEvent() );
|
||||
*/
|
||||
|
||||
Go( &SCH_EDITOR_CONTROL::HighlightNet, SCH_ACTIONS::highlightNet.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::ClearHighlight, SCH_ACTIONS::clearHighlight.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::HighlightNetCursor, SCH_ACTIONS::highlightNetCursor.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::HighlightNetSelection, SCH_ACTIONS::highlightNetSelection.MakeEvent() );
|
||||
}
|
||||
|
@ -62,6 +62,9 @@ public:
|
||||
///> Highlights net under the cursor.
|
||||
int HighlightNet( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> Removes any net highlighting
|
||||
int ClearHighlight( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> Highlights frame's SelectedNetName.
|
||||
int HighlightNetSelection( const TOOL_EVENT& aEvent );
|
||||
|
||||
@ -73,8 +76,9 @@ private:
|
||||
///> Sets up handlers for various events.
|
||||
void setTransitions() override;
|
||||
|
||||
///> Pointer to the currently used edit frame.
|
||||
SCH_EDIT_FRAME* m_frame;
|
||||
SCH_EDIT_FRAME* m_frame; ///> Pointer to the currently used edit frame
|
||||
|
||||
bool m_probingSchToPcb; ///> Recursion guard when cross-probing to PCBNew
|
||||
|
||||
/// Menu model displayed by the tool.
|
||||
TOOL_MENU m_menu;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user