Move Eeschema net highlighting to modern toolset.
This commit is contained in:
parent
91bf08df1a
commit
b63fab92cf
|
@ -158,14 +158,13 @@ set( EESCHEMA_SRCS
|
||||||
eeschema.cpp
|
eeschema.cpp
|
||||||
eeschema_config.cpp
|
eeschema_config.cpp
|
||||||
erc.cpp
|
erc.cpp
|
||||||
events_called_functions_for_edit.cpp
|
|
||||||
fields_grid_table.cpp
|
fields_grid_table.cpp
|
||||||
files-io.cpp
|
files-io.cpp
|
||||||
find.cpp
|
find.cpp
|
||||||
generate_alias_info.cpp
|
generate_alias_info.cpp
|
||||||
getpart.cpp
|
getpart.cpp
|
||||||
hierarch.cpp
|
hierarch.cpp
|
||||||
highlight_connection.cpp
|
tools/sch_editor_control.cpp
|
||||||
hotkeys.cpp
|
hotkeys.cpp
|
||||||
lib_arc.cpp
|
lib_arc.cpp
|
||||||
lib_bezier.cpp
|
lib_bezier.cpp
|
||||||
|
@ -244,7 +243,8 @@ set( EESCHEMA_SRCS
|
||||||
netlist_exporters/netlist_exporter_pspice.cpp
|
netlist_exporters/netlist_exporter_pspice.cpp
|
||||||
|
|
||||||
tools/sch_actions.cpp
|
tools/sch_actions.cpp
|
||||||
tools/tools_common.cpp
|
tools/sch_picker_tool.cpp
|
||||||
|
tools/selection.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,6 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @file eeschema/cross-probing.cpp
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <fctsys.h>
|
#include <fctsys.h>
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
#include <kiface_i.h>
|
#include <kiface_i.h>
|
||||||
|
@ -34,7 +30,7 @@
|
||||||
#include <macros.h>
|
#include <macros.h>
|
||||||
#include <eda_dde.h>
|
#include <eda_dde.h>
|
||||||
#include <sch_draw_panel.h>
|
#include <sch_draw_panel.h>
|
||||||
|
#include <tool/tool_manager.h>
|
||||||
#include <sch_edit_frame.h>
|
#include <sch_edit_frame.h>
|
||||||
#include <general.h>
|
#include <general.h>
|
||||||
#include <eeschema_id.h>
|
#include <eeschema_id.h>
|
||||||
|
@ -45,6 +41,7 @@
|
||||||
#include <sch_view.h>
|
#include <sch_view.h>
|
||||||
#include <reporter.h>
|
#include <reporter.h>
|
||||||
#include <netlist_exporters/netlist_exporter_kicad.h>
|
#include <netlist_exporters/netlist_exporter_kicad.h>
|
||||||
|
#include <tools/sch_actions.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a remote command sent by Pcbnew via a socket connection.
|
* Execute a remote command sent by Pcbnew via a socket connection.
|
||||||
|
@ -79,22 +76,13 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
|
||||||
|
|
||||||
if( strcmp( idcmd, "$NET:" ) == 0 )
|
if( strcmp( idcmd, "$NET:" ) == 0 )
|
||||||
{
|
{
|
||||||
if( GetToolId() == ID_HIGHLIGHT )
|
if( GetToolId() == ID_HIGHLIGHT_BUTT )
|
||||||
{
|
{
|
||||||
m_SelectedNetName = FROM_UTF8( text );
|
m_SelectedNetName = FROM_UTF8( text );
|
||||||
|
|
||||||
SetStatusText( _( "Selected net: " ) + UnescapeString( m_SelectedNetName ) );
|
SetStatusText( _( "Selected net: " ) + UnescapeString( m_SelectedNetName ) );
|
||||||
std::vector<EDA_ITEM*> itemsToRedraw;
|
|
||||||
SetCurrentSheetHighlightFlags( &itemsToRedraw );
|
|
||||||
|
|
||||||
// Be sure hightlight change will be redrawn
|
GetToolManager()->RunAction( SCH_ACTIONS::highlightNetSelection, true );
|
||||||
KIGFX::VIEW* view = GetGalCanvas()->GetView();
|
|
||||||
|
|
||||||
for( auto item : itemsToRedraw )
|
|
||||||
view->Update( (KIGFX::VIEW_ITEM*)item, KIGFX::VIEW_UPDATE_FLAGS::REPAINT );
|
|
||||||
|
|
||||||
//view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
|
||||||
GetGalCanvas()->Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||||
* Copyright (C) 2008-2017 KiCad Developers, see change_log.txt for contributors.
|
* Copyright (C) 2008-2019 KiCad Developers, see change_log.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -22,14 +22,9 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @file eeschema_id.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __EESCHEMA_ID_H__
|
#ifndef __EESCHEMA_ID_H__
|
||||||
#define __EESCHEMA_ID_H__
|
#define __EESCHEMA_ID_H__
|
||||||
|
|
||||||
|
|
||||||
#include <id.h>
|
#include <id.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,7 +77,7 @@ enum id_eeschema_frm
|
||||||
|
|
||||||
/* Schematic editor vertical toolbar IDs */
|
/* Schematic editor vertical toolbar IDs */
|
||||||
ID_SCHEMATIC_VERTICAL_TOOLBAR_START,
|
ID_SCHEMATIC_VERTICAL_TOOLBAR_START,
|
||||||
ID_HIGHLIGHT,
|
ID_HIGHLIGHT_BUTT,
|
||||||
ID_SCH_PLACE_COMPONENT,
|
ID_SCH_PLACE_COMPONENT,
|
||||||
ID_PLACE_POWER_BUTT,
|
ID_PLACE_POWER_BUTT,
|
||||||
ID_BUS_BUTT,
|
ID_BUS_BUTT,
|
||||||
|
@ -214,6 +209,7 @@ enum id_eeschema_frm
|
||||||
ID_CANCEL_CURRENT_COMMAND,
|
ID_CANCEL_CURRENT_COMMAND,
|
||||||
|
|
||||||
ID_HOTKEY_HIGHLIGHT,
|
ID_HOTKEY_HIGHLIGHT,
|
||||||
|
ID_HIGHLIGHT_NET,
|
||||||
|
|
||||||
/* Library editor: edit events */
|
/* Library editor: edit events */
|
||||||
ID_LIBEDIT_NEW_LIBRARY,
|
ID_LIBEDIT_NEW_LIBRARY,
|
||||||
|
@ -240,9 +236,7 @@ enum id_eeschema_frm
|
||||||
ID_LIBEDIT_VIEW_DOC,
|
ID_LIBEDIT_VIEW_DOC,
|
||||||
ID_LIBEDIT_CHECK_PART,
|
ID_LIBEDIT_CHECK_PART,
|
||||||
ID_LIBEDIT_GET_FRAME_EDIT_PART,
|
ID_LIBEDIT_GET_FRAME_EDIT_PART,
|
||||||
|
|
||||||
ID_LIBEDIT_SELECT_PART_NUMBER,
|
ID_LIBEDIT_SELECT_PART_NUMBER,
|
||||||
ID_LIBEDIT_SELECT_ALIAS,
|
|
||||||
|
|
||||||
/* Library editor vertical toolbar IDs. */
|
/* Library editor vertical toolbar IDs. */
|
||||||
ID_LIBEDIT_PIN_BUTT,
|
ID_LIBEDIT_PIN_BUTT,
|
||||||
|
@ -295,8 +289,6 @@ enum id_eeschema_frm
|
||||||
ID_LIBVIEW_SELECT_PART_NUMBER,
|
ID_LIBVIEW_SELECT_PART_NUMBER,
|
||||||
ID_LIBVIEW_LIB_LIST,
|
ID_LIBVIEW_LIB_LIST,
|
||||||
ID_LIBVIEW_CMP_LIST,
|
ID_LIBVIEW_CMP_LIST,
|
||||||
ID_LIBVIEW_LIBWINDOW,
|
|
||||||
ID_LIBVIEW_CMPWINDOW,
|
|
||||||
ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC,
|
ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC,
|
||||||
ID_SET_RELATIVE_OFFSET,
|
ID_SET_RELATIVE_OFFSET,
|
||||||
ID_LIBVIEW_SHOW_ELECTRICAL_TYPE,
|
ID_LIBVIEW_SHOW_ELECTRICAL_TYPE,
|
||||||
|
|
|
@ -1,78 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
||||||
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, you may find one here:
|
|
||||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
||||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
||||||
* or you may write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @file events_called_functions.cpp
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <fctsys.h>
|
|
||||||
#include <gr_basic.h>
|
|
||||||
#include <sch_draw_panel.h>
|
|
||||||
#include <general.h>
|
|
||||||
#include <kicad_device_context.h>
|
|
||||||
#include <sch_edit_frame.h>
|
|
||||||
#include <sch_component.h>
|
|
||||||
#include <sch_text.h>
|
|
||||||
#include <view/view_controls.h>
|
|
||||||
|
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
|
|
||||||
{
|
|
||||||
SCH_ITEM * curr_item = GetScreen()->GetCurItem();
|
|
||||||
|
|
||||||
if( !curr_item || curr_item->GetFlags() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
GetCanvas()->GetViewControls()->SetCursorPosition( GetCrossHairPosition() );
|
|
||||||
|
|
||||||
switch( curr_item->Type() )
|
|
||||||
{
|
|
||||||
case SCH_COMPONENT_T:
|
|
||||||
{
|
|
||||||
SCH_COMPONENT* newitem;
|
|
||||||
newitem = new SCH_COMPONENT( *( (SCH_COMPONENT*) curr_item ) );
|
|
||||||
newitem->SetTimeStamp( GetNewTimeStamp() );
|
|
||||||
newitem->ClearAnnotation( NULL );
|
|
||||||
newitem->SetFlags( IS_NEW );
|
|
||||||
// Draw the new part, MoveItem() expects it to be already on screen.
|
|
||||||
PrepareMoveItem( newitem );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SCH_TEXT_T:
|
|
||||||
case SCH_LABEL_T:
|
|
||||||
case SCH_GLOBAL_LABEL_T:
|
|
||||||
case SCH_HIERARCHICAL_LABEL_T:
|
|
||||||
{
|
|
||||||
SCH_TEXT* newitem = (SCH_TEXT*) curr_item->Clone();
|
|
||||||
newitem->SetFlags( IS_NEW );
|
|
||||||
// Draw the new item, MoveItem() expects it to be already on screen.
|
|
||||||
PrepareMoveItem( newitem );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -23,10 +23,6 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @file hierarch.cpp
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <fctsys.h>
|
#include <fctsys.h>
|
||||||
#include <sch_draw_panel.h>
|
#include <sch_draw_panel.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
|
@ -41,7 +37,8 @@
|
||||||
|
|
||||||
#include <wx/imaglist.h>
|
#include <wx/imaglist.h>
|
||||||
#include <wx/treectrl.h>
|
#include <wx/treectrl.h>
|
||||||
|
#include <tool/tool_manager.h>
|
||||||
|
#include <tools/sch_actions.h>
|
||||||
#include <netlist_object.h>
|
#include <netlist_object.h>
|
||||||
#include <sch_sheet_path.h>
|
#include <sch_sheet_path.h>
|
||||||
|
|
||||||
|
@ -91,8 +88,7 @@ HIERARCHY_TREE::HIERARCHY_TREE( HIERARCHY_NAVIG_DLG* parent ) :
|
||||||
// Make an image list containing small icons
|
// Make an image list containing small icons
|
||||||
// All icons are expected having the same size.
|
// All icons are expected having the same size.
|
||||||
wxBitmap tree_nosel_bm( KiBitmap( tree_nosel_xpm ) );
|
wxBitmap tree_nosel_bm( KiBitmap( tree_nosel_xpm ) );
|
||||||
imageList = new wxImageList( tree_nosel_bm.GetWidth(),
|
imageList = new wxImageList( tree_nosel_bm.GetWidth(), tree_nosel_bm.GetHeight(), true, 2 );
|
||||||
tree_nosel_bm.GetHeight(), true, 2 );
|
|
||||||
|
|
||||||
imageList->Add( tree_nosel_bm );
|
imageList->Add( tree_nosel_bm );
|
||||||
imageList->Add( KiBitmap( tree_sel_xpm ) );
|
imageList->Add( KiBitmap( tree_sel_xpm ) );
|
||||||
|
@ -116,9 +112,6 @@ public:
|
||||||
|
|
||||||
~HIERARCHY_NAVIG_DLG();
|
~HIERARCHY_NAVIG_DLG();
|
||||||
|
|
||||||
// Select the sheet currently selected in the tree, and close the dialog
|
|
||||||
void SelectNewSheetAndQuit();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Create the hierarchical tree of the schematic.
|
* Create the hierarchical tree of the schematic.
|
||||||
|
@ -158,8 +151,7 @@ HIERARCHY_NAVIG_DLG::HIERARCHY_NAVIG_DLG( SCH_EDIT_FRAME* aParent, const wxPoint
|
||||||
m_nbsheets = 1;
|
m_nbsheets = 1;
|
||||||
|
|
||||||
// root is the link to the main sheet.
|
// root is the link to the main sheet.
|
||||||
wxTreeItemId root;
|
wxTreeItemId root = m_Tree->AddRoot( _( "Root" ), 0, 1 );
|
||||||
root = m_Tree->AddRoot( _( "Root" ), 0, 1 );
|
|
||||||
m_Tree->SetItemBold( root, true );
|
m_Tree->SetItemBold( root, true );
|
||||||
|
|
||||||
SCH_SHEET_PATH list;
|
SCH_SHEET_PATH list;
|
||||||
|
@ -292,10 +284,8 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
|
||||||
RedrawScreen( GetScrollCenterPosition(), false );
|
RedrawScreen( GetScrollCenterPosition(), false );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some items (wires, labels) can be highlighted. So prepare the highlight flag:
|
|
||||||
SetCurrentSheetHighlightFlags( nullptr );
|
|
||||||
|
|
||||||
UpdateTitle();
|
UpdateTitle();
|
||||||
|
|
||||||
|
GetToolManager()->RunAction( SCH_ACTIONS::highlightNetSelection, true );
|
||||||
GetCanvas()->Refresh();
|
GetCanvas()->Refresh();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,154 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, you may find one here:
|
|
||||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
||||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
||||||
* or you may write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file highlight_connection.cpp
|
|
||||||
* @brief This file contains basic functions related to the command to
|
|
||||||
* highlight a connection (wires and labels) in a schematic
|
|
||||||
* (that can be a simple or a complex hierarchy)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <fctsys.h>
|
|
||||||
#include <sch_view.h>
|
|
||||||
#include <sch_draw_panel.h>
|
|
||||||
#include <sch_edit_frame.h>
|
|
||||||
#include <sch_component.h>
|
|
||||||
#include <erc.h>
|
|
||||||
|
|
||||||
#include <netlist_object.h>
|
|
||||||
#include <sch_component.h>
|
|
||||||
#include <sch_sheet.h>
|
|
||||||
|
|
||||||
// List of items having the highlight option modified, therefore need to be redrawn
|
|
||||||
|
|
||||||
// TODO(JE) Probably use netcode rather than connection name here eventually
|
|
||||||
bool SCH_EDIT_FRAME::HighlightConnectionAtPosition( wxPoint aPosition )
|
|
||||||
{
|
|
||||||
std::vector<EDA_ITEM*> itemsToRedraw;
|
|
||||||
m_SelectedNetName = "";
|
|
||||||
bool buildNetlistOk = false;
|
|
||||||
|
|
||||||
SetStatusText( "" );
|
|
||||||
|
|
||||||
// find which connected item is selected
|
|
||||||
EDA_ITEMS nodeList;
|
|
||||||
wxPoint gridPosition = GetGridPosition( aPosition );
|
|
||||||
|
|
||||||
if( GetScreen()->GetNode( gridPosition, nodeList ) )
|
|
||||||
{
|
|
||||||
if( TestDuplicateSheetNames( false ) > 0 )
|
|
||||||
wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet. Fix it" ) );
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( auto item = dynamic_cast<SCH_ITEM*>( nodeList[0] ) )
|
|
||||||
{
|
|
||||||
if( item->Connection( *g_CurrentSheet ) )
|
|
||||||
{
|
|
||||||
m_SelectedNetName = item->Connection( *g_CurrentSheet )->Name();
|
|
||||||
SetStatusText( _( "Highlighted net: " ) + m_SelectedNetName );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SendCrossProbeNetName( m_SelectedNetName );
|
|
||||||
SetStatusText( _( "Selected net: " ) + UnescapeString( m_SelectedNetName ) );
|
|
||||||
SetCurrentSheetHighlightFlags( &itemsToRedraw );
|
|
||||||
|
|
||||||
// Be sure hightlight change will be redrawn
|
|
||||||
KIGFX::VIEW* view = GetGalCanvas()->GetView();
|
|
||||||
|
|
||||||
for( auto item : itemsToRedraw )
|
|
||||||
view->Update( (KIGFX::VIEW_ITEM*)item, KIGFX::VIEW_UPDATE_FLAGS::REPAINT );
|
|
||||||
|
|
||||||
//view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
|
||||||
GetGalCanvas()->Refresh();
|
|
||||||
return buildNetlistOk;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool SCH_EDIT_FRAME::SetCurrentSheetHighlightFlags( std::vector<EDA_ITEM*>* aItemsToRedrawList )
|
|
||||||
{
|
|
||||||
SCH_SCREEN* screen = g_CurrentSheet->LastScreen();
|
|
||||||
|
|
||||||
if( !screen )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
for( SCH_ITEM* ptr = screen->GetDrawItems(); ptr; ptr = ptr->Next() )
|
|
||||||
{
|
|
||||||
auto conn = ptr->Connection( *g_CurrentSheet );
|
|
||||||
bool redraw = ptr->GetState( BRIGHTENED );
|
|
||||||
|
|
||||||
ptr->SetState( BRIGHTENED, ( conn && conn->Name() == m_SelectedNetName ) );
|
|
||||||
|
|
||||||
redraw |= ptr->GetState( BRIGHTENED );
|
|
||||||
|
|
||||||
if( ptr->Type() == SCH_COMPONENT_T )
|
|
||||||
{
|
|
||||||
SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( ptr );
|
|
||||||
|
|
||||||
redraw |= comp->HasBrightenedPins();
|
|
||||||
|
|
||||||
comp->ClearBrightenedPins();
|
|
||||||
std::vector<LIB_PIN*> pins;
|
|
||||||
comp->GetPins( pins );
|
|
||||||
|
|
||||||
for( LIB_PIN* pin : pins )
|
|
||||||
{
|
|
||||||
auto pin_conn = comp->GetConnectionForPin( pin, *g_CurrentSheet );
|
|
||||||
|
|
||||||
if( pin_conn && pin_conn->Name( false ) == m_SelectedNetName )
|
|
||||||
{
|
|
||||||
comp->BrightenPin( pin );
|
|
||||||
redraw = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( ptr->Type() == SCH_SHEET_T )
|
|
||||||
{
|
|
||||||
for( SCH_SHEET_PIN& pin : static_cast<SCH_SHEET*>( ptr )->GetPins() )
|
|
||||||
{
|
|
||||||
auto pin_conn = pin.Connection( *g_CurrentSheet );
|
|
||||||
bool redrawPin = pin.GetState( BRIGHTENED );
|
|
||||||
|
|
||||||
pin.SetState( BRIGHTENED, ( pin_conn && pin_conn->Name() == m_SelectedNetName ) );
|
|
||||||
|
|
||||||
redrawPin |= pin.GetState( BRIGHTENED );
|
|
||||||
|
|
||||||
if( redrawPin && aItemsToRedrawList )
|
|
||||||
aItemsToRedrawList->push_back( &pin );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( redraw && aItemsToRedrawList )
|
|
||||||
aItemsToRedrawList->push_back( ptr );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( m_SelectedNetName == "" )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if( TestDuplicateSheetNames( false ) > 0 )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@verizon.net>
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@verizon.net>
|
||||||
* Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -23,10 +23,6 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @file eeschema/hotkeys.cpp
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <fctsys.h>
|
#include <fctsys.h>
|
||||||
#include <eeschema_id.h>
|
#include <eeschema_id.h>
|
||||||
#include <hotkeys.h>
|
#include <hotkeys.h>
|
||||||
|
@ -86,8 +82,7 @@
|
||||||
#if !defined( __WXMAC__ )
|
#if !defined( __WXMAC__ )
|
||||||
static EDA_HOTKEY HkZoomAuto( _HKI( "Fit on Screen" ), HK_ZOOM_AUTO, WXK_HOME, ID_ZOOM_PAGE );
|
static EDA_HOTKEY HkZoomAuto( _HKI( "Fit on Screen" ), HK_ZOOM_AUTO, WXK_HOME, ID_ZOOM_PAGE );
|
||||||
#else
|
#else
|
||||||
static EDA_HOTKEY HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, GR_KB_CTRL + '0',
|
static EDA_HOTKEY HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, GR_KB_CTRL + '0', ID_ZOOM_PAGE );
|
||||||
ID_ZOOM_PAGE );
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static EDA_HOTKEY HkZoomCenter( _HKI( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4,
|
static EDA_HOTKEY HkZoomCenter( _HKI( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4,
|
||||||
|
@ -161,8 +156,7 @@ static EDA_HOTKEY HkOrientNormalComponent( _HKI( "Orient Normal Component" ),
|
||||||
HK_ORIENT_NORMAL_COMPONENT, 'N', ID_SCH_ORIENT_NORMAL );
|
HK_ORIENT_NORMAL_COMPONENT, 'N', ID_SCH_ORIENT_NORMAL );
|
||||||
static EDA_HOTKEY HkRotate( _HKI( "Rotate Item" ), HK_ROTATE, 'R', ID_SCH_ROTATE_CLOCKWISE );
|
static EDA_HOTKEY HkRotate( _HKI( "Rotate Item" ), HK_ROTATE, 'R', ID_SCH_ROTATE_CLOCKWISE );
|
||||||
static EDA_HOTKEY HkEdit( _HKI( "Edit Item" ), HK_EDIT, 'E', ID_SCH_EDIT_ITEM );
|
static EDA_HOTKEY HkEdit( _HKI( "Edit Item" ), HK_EDIT, 'E', ID_SCH_EDIT_ITEM );
|
||||||
static EDA_HOTKEY HkEditComponentValue( _HKI( "Edit Symbol Value" ),
|
static EDA_HOTKEY HkEditComponentValue( _HKI( "Edit Symbol Value" ), HK_EDIT_COMPONENT_VALUE, 'V',
|
||||||
HK_EDIT_COMPONENT_VALUE, 'V',
|
|
||||||
ID_SCH_EDIT_COMPONENT_VALUE );
|
ID_SCH_EDIT_COMPONENT_VALUE );
|
||||||
static EDA_HOTKEY HkEditComponentReference( _HKI( "Edit Symbol Reference" ),
|
static EDA_HOTKEY HkEditComponentReference( _HKI( "Edit Symbol Reference" ),
|
||||||
HK_EDIT_COMPONENT_REFERENCE, 'U',
|
HK_EDIT_COMPONENT_REFERENCE, 'U',
|
||||||
|
@ -177,8 +171,7 @@ static EDA_HOTKEY HkEditComponentWithLibedit( _HKI( "Edit with Symbol Editor" ),
|
||||||
HK_EDIT_COMPONENT_WITH_LIBEDIT, 'E' + GR_KB_CTRL,
|
HK_EDIT_COMPONENT_WITH_LIBEDIT, 'E' + GR_KB_CTRL,
|
||||||
ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP );
|
ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP );
|
||||||
|
|
||||||
static EDA_HOTKEY HkMove( _HKI( "Move Schematic Item" ),
|
static EDA_HOTKEY HkMove( _HKI( "Move Schematic Item" ), HK_MOVE_COMPONENT_OR_ITEM, 'M',
|
||||||
HK_MOVE_COMPONENT_OR_ITEM, 'M',
|
|
||||||
ID_SCH_MOVE_ITEM );
|
ID_SCH_MOVE_ITEM );
|
||||||
|
|
||||||
static EDA_HOTKEY HkDuplicateItem( _HKI( "Duplicate Symbol or Label" ),
|
static EDA_HOTKEY HkDuplicateItem( _HKI( "Duplicate Symbol or Label" ),
|
||||||
|
@ -221,8 +214,7 @@ static EDA_HOTKEY HkUpdatePcbFromSch( _HKI( "Update PCB from Schematic" ), HK_UP
|
||||||
static EDA_HOTKEY HkHighlightConnection( _HKI( "Highlight Connection" ), ID_HOTKEY_HIGHLIGHT,
|
static EDA_HOTKEY HkHighlightConnection( _HKI( "Highlight Connection" ), ID_HOTKEY_HIGHLIGHT,
|
||||||
'B' + GR_KB_CTRL );
|
'B' + GR_KB_CTRL );
|
||||||
|
|
||||||
static EDA_HOTKEY HkUnfoldBus( _HKI( "Unfold Bus" ), HK_UNFOLD_BUS, 'D',
|
static EDA_HOTKEY HkUnfoldBus( _HKI( "Unfold Bus" ), HK_UNFOLD_BUS, 'D', ID_SCH_UNFOLD_BUS );
|
||||||
ID_SCH_UNFOLD_BUS );
|
|
||||||
|
|
||||||
// Common: hotkeys_basic.h
|
// Common: hotkeys_basic.h
|
||||||
static EDA_HOTKEY HkNew( _HKI( "New" ), HK_NEW, GR_KB_CTRL + 'N', (int) wxID_NEW );
|
static EDA_HOTKEY HkNew( _HKI( "New" ), HK_NEW, GR_KB_CTRL + 'N', (int) wxID_NEW );
|
||||||
|
@ -237,9 +229,7 @@ static EDA_HOTKEY HkUndo( _HKI( "Undo" ), HK_UNDO, GR_KB_CTRL + 'Z', (int) wxID_
|
||||||
#if !defined( __WXMAC__ )
|
#if !defined( __WXMAC__ )
|
||||||
static EDA_HOTKEY HkRedo( _HKI( "Redo" ), HK_REDO, GR_KB_CTRL + 'Y', (int) wxID_REDO );
|
static EDA_HOTKEY HkRedo( _HKI( "Redo" ), HK_REDO, GR_KB_CTRL + 'Y', (int) wxID_REDO );
|
||||||
#else
|
#else
|
||||||
static EDA_HOTKEY HkRedo( _HKI( "Redo" ), HK_REDO,
|
static EDA_HOTKEY HkRedo( _HKI( "Redo" ), HK_REDO, GR_KB_SHIFTCTRL + 'Z', (int) wxID_REDO );
|
||||||
GR_KB_SHIFT + GR_KB_CTRL + 'Z',
|
|
||||||
(int) wxID_REDO );
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static EDA_HOTKEY HkEditCut( _HKI( "Cut" ), HK_EDIT_CUT, GR_KB_CTRL + 'X', (int) wxID_CUT );
|
static EDA_HOTKEY HkEditCut( _HKI( "Cut" ), HK_EDIT_CUT, GR_KB_CTRL + 'X', (int) wxID_CUT );
|
||||||
|
@ -479,7 +469,10 @@ bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||||
|
|
||||||
case ID_HOTKEY_HIGHLIGHT:
|
case ID_HOTKEY_HIGHLIGHT:
|
||||||
if( notBusy )
|
if( notBusy )
|
||||||
HighlightConnectionAtPosition( GetCrossHairPosition() );
|
{
|
||||||
|
cmd.SetId( ID_HIGHLIGHT_NET );
|
||||||
|
GetEventHandler()->ProcessEvent( cmd );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HK_LEFT_CLICK:
|
case HK_LEFT_CLICK:
|
||||||
|
|
|
@ -119,8 +119,8 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
|
||||||
case ID_ZOOM_SELECTION:
|
case ID_ZOOM_SELECTION:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_HIGHLIGHT:
|
case ID_HIGHLIGHT_BUTT:
|
||||||
HighlightConnectionAtPosition( aPosition );
|
// JEY TODO....
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_NOCONN_BUTT:
|
case ID_NOCONN_BUTT:
|
||||||
|
|
|
@ -254,7 +254,7 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
|
||||||
EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
|
EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
|
||||||
EVT_MENU( ID_POPUP_SCH_SELECT_ON_PCB, SCH_EDIT_FRAME::SelectAllFromSheet )
|
EVT_MENU( ID_POPUP_SCH_SELECT_ON_PCB, SCH_EDIT_FRAME::SelectAllFromSheet )
|
||||||
|
|
||||||
EVT_MENU( ID_POPUP_SCH_DUPLICATE_ITEM, SCH_EDIT_FRAME::OnCopySchematicItemRequest )
|
EVT_MENU( ID_POPUP_SCH_DUPLICATE_ITEM, SCH_EDIT_FRAME::OnDuplicateItem )
|
||||||
|
|
||||||
EVT_MENU( ID_CONFIG_SAVE, SCH_EDIT_FRAME::Process_Config )
|
EVT_MENU( ID_CONFIG_SAVE, SCH_EDIT_FRAME::Process_Config )
|
||||||
EVT_MENU( ID_CONFIG_READ, SCH_EDIT_FRAME::Process_Config )
|
EVT_MENU( ID_CONFIG_READ, SCH_EDIT_FRAME::Process_Config )
|
||||||
|
@ -304,7 +304,7 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
|
||||||
|
|
||||||
// Tools and buttons for vertical toolbar.
|
// Tools and buttons for vertical toolbar.
|
||||||
EVT_TOOL( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnSelectTool )
|
EVT_TOOL( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnSelectTool )
|
||||||
EVT_TOOL( ID_HIGHLIGHT, SCH_EDIT_FRAME::OnSelectTool )
|
EVT_TOOL( ID_HIGHLIGHT_BUTT, SCH_EDIT_FRAME::OnSelectTool )
|
||||||
EVT_MENU( ID_MENU_ZOOM_SELECTION, SCH_EDIT_FRAME::OnSelectTool )
|
EVT_MENU( ID_MENU_ZOOM_SELECTION, SCH_EDIT_FRAME::OnSelectTool )
|
||||||
EVT_TOOL( ID_ZOOM_SELECTION, SCH_EDIT_FRAME::OnSelectTool )
|
EVT_TOOL( ID_ZOOM_SELECTION, SCH_EDIT_FRAME::OnSelectTool )
|
||||||
EVT_TOOL_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
|
EVT_TOOL_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
|
||||||
|
@ -352,7 +352,7 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
|
||||||
EVT_UPDATE_UI( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnUpdateHiddenPins )
|
EVT_UPDATE_UI( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnUpdateHiddenPins )
|
||||||
EVT_UPDATE_UI( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnUpdateBusOrientation )
|
EVT_UPDATE_UI( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnUpdateBusOrientation )
|
||||||
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnUpdateSelectTool )
|
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnUpdateSelectTool )
|
||||||
EVT_UPDATE_UI( ID_HIGHLIGHT, SCH_EDIT_FRAME::OnUpdateSelectTool )
|
EVT_UPDATE_UI( ID_HIGHLIGHT_BUTT, SCH_EDIT_FRAME::OnUpdateSelectTool )
|
||||||
EVT_UPDATE_UI( ID_ZOOM_SELECTION, SCH_EDIT_FRAME::OnUpdateSelectTool )
|
EVT_UPDATE_UI( ID_ZOOM_SELECTION, SCH_EDIT_FRAME::OnUpdateSelectTool )
|
||||||
EVT_UPDATE_UI_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
|
EVT_UPDATE_UI_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
|
||||||
SCH_EDIT_FRAME::OnUpdateSelectTool )
|
SCH_EDIT_FRAME::OnUpdateSelectTool )
|
||||||
|
|
|
@ -458,17 +458,6 @@ public:
|
||||||
bool DeleteItemAtCrossHair();
|
bool DeleteItemAtCrossHair();
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Highlight the connection found at aPosition.
|
|
||||||
*
|
|
||||||
* If no connection to highlight is found, clear the current highlighted connect (if any).
|
|
||||||
*
|
|
||||||
* @param aPosition is the location of the test point (usually cross hair position).
|
|
||||||
* @return true if OK, false if there was an issue to build the netlist
|
|
||||||
* needed to highlight a connection.
|
|
||||||
*/
|
|
||||||
bool HighlightConnectionAtPosition( wxPoint aPosition );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds a component in the schematic and an item in this component.
|
* Finds a component in the schematic and an item in this component.
|
||||||
*
|
*
|
||||||
|
@ -541,12 +530,15 @@ public:
|
||||||
void SendMessageToPCBNEW( EDA_ITEM* aObjectToSync, SCH_COMPONENT* aPart );
|
void SendMessageToPCBNEW( EDA_ITEM* aObjectToSync, SCH_COMPONENT* aPart );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a net name to eeschema for highlighting
|
* Sends a net name to pcbnew for highlighting
|
||||||
*
|
*
|
||||||
* @param aNetName is the name of a net, or empty string to clear highlight
|
* @param aNetName is the name of a net, or empty string to clear highlight
|
||||||
*/
|
*/
|
||||||
void SendCrossProbeNetName( const wxString& aNetName );
|
void SendCrossProbeNetName( const wxString& aNetName );
|
||||||
|
|
||||||
|
const wxString& GetSelectedNetName() const { return m_SelectedNetName; }
|
||||||
|
void SetSelectedNetName( const wxString& aNetName ) { m_SelectedNetName = aNetName; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a flat list which stores all connected objects.
|
* Create a flat list which stores all connected objects.
|
||||||
*
|
*
|
||||||
|
@ -680,18 +672,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void OnPageSettingsChange() override;
|
void OnPageSettingsChange() override;
|
||||||
|
|
||||||
/**
|
|
||||||
* Set or reset the BRIGHTENED of connected objects inside the current sheet,
|
|
||||||
* according to the highlighted net name.
|
|
||||||
*
|
|
||||||
* @param aItemsToRedrawList is the list of modified items (flag BRIGHTENED modified)
|
|
||||||
* that must be redrawn.
|
|
||||||
* Can be NULL
|
|
||||||
* @return true if the flags are correctly set, and false if something goes wrong
|
|
||||||
* (duplicate sheet names)
|
|
||||||
*/
|
|
||||||
bool SetCurrentSheetHighlightFlags( std::vector<EDA_ITEM*>* aItemsToRedrawList );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a filename that can be used in plot and print functions
|
* @return a filename that can be used in plot and print functions
|
||||||
* for the current screen and sheet path.
|
* for the current screen and sheet path.
|
||||||
|
@ -953,7 +933,7 @@ private:
|
||||||
/**
|
/**
|
||||||
* Command event handler for duplicating the item at the current location.
|
* Command event handler for duplicating the item at the current location.
|
||||||
*/
|
*/
|
||||||
void OnCopySchematicItemRequest( wxCommandEvent& event );
|
void OnDuplicateItem( wxCommandEvent& event );
|
||||||
|
|
||||||
/* User interface update event handlers. */
|
/* User interface update event handlers. */
|
||||||
void OnUpdatePaste( wxUpdateUIEvent& event );
|
void OnUpdatePaste( wxUpdateUIEvent& event );
|
||||||
|
|
|
@ -23,10 +23,6 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @file schedit.cpp
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <fctsys.h>
|
#include <fctsys.h>
|
||||||
#include <kiway.h>
|
#include <kiway.h>
|
||||||
#include <gr_basic.h>
|
#include <gr_basic.h>
|
||||||
|
@ -369,8 +365,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// End switch ( id ) (Command execution)
|
|
||||||
|
|
||||||
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
||||||
SetRepeatItem( NULL );
|
SetRepeatItem( NULL );
|
||||||
}
|
}
|
||||||
|
@ -451,16 +445,54 @@ void SCH_EDIT_FRAME::FinishBusUnfold()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SCH_EDIT_FRAME::OnDuplicateItem( wxCommandEvent& event )
|
||||||
|
{
|
||||||
|
SCH_ITEM* curr_item = GetScreen()->GetCurItem();
|
||||||
|
|
||||||
|
if( !curr_item || curr_item->GetFlags() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
GetCanvas()->GetViewControls()->SetCursorPosition( GetCrossHairPosition() );
|
||||||
|
|
||||||
|
switch( curr_item->Type() )
|
||||||
|
{
|
||||||
|
case SCH_COMPONENT_T:
|
||||||
|
{
|
||||||
|
SCH_COMPONENT* newitem = new SCH_COMPONENT( *( (SCH_COMPONENT*) curr_item ) );
|
||||||
|
newitem->SetTimeStamp( GetNewTimeStamp() );
|
||||||
|
newitem->ClearAnnotation( NULL );
|
||||||
|
newitem->SetFlags( IS_NEW );
|
||||||
|
// Draw the new part, MoveItem() expects it to be already on screen.
|
||||||
|
PrepareMoveItem( newitem );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SCH_TEXT_T:
|
||||||
|
case SCH_LABEL_T:
|
||||||
|
case SCH_GLOBAL_LABEL_T:
|
||||||
|
case SCH_HIERARCHICAL_LABEL_T:
|
||||||
|
{
|
||||||
|
SCH_TEXT* newitem = (SCH_TEXT*) curr_item->Clone();
|
||||||
|
newitem->SetFlags( IS_NEW );
|
||||||
|
// Draw the new item, MoveItem() expects it to be already on screen.
|
||||||
|
PrepareMoveItem( newitem );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
|
void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
SCH_SCREEN* screen = GetScreen();
|
SCH_SCREEN* screen = GetScreen();
|
||||||
SCH_ITEM* item = screen->GetCurItem();
|
SCH_ITEM* item = screen->GetCurItem();
|
||||||
|
|
||||||
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
|
||||||
{
|
|
||||||
// trying to move an item when there is a block at the same time is not acceptable
|
// 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 )
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if( item == NULL )
|
if( item == NULL )
|
||||||
{
|
{
|
||||||
|
@ -560,12 +592,12 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
||||||
SetNoToolSelected();
|
SetNoToolSelected();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_HIGHLIGHT:
|
case ID_HIGHLIGHT_BUTT:
|
||||||
// TODO(JE) remove once real-time connectivity is a given
|
// TODO(JE) remove once real-time connectivity is a given
|
||||||
if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity )
|
if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity )
|
||||||
RecalculateConnections();
|
RecalculateConnections();
|
||||||
|
|
||||||
SetToolID( ID_HIGHLIGHT, wxCURSOR_HAND, _("Highlight specific net") );
|
SetToolID( ID_HIGHLIGHT_BUTT, wxCURSOR_HAND, _("Highlight specific net") );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_MENU_ZOOM_SELECTION:
|
case ID_MENU_ZOOM_SELECTION:
|
||||||
|
@ -852,11 +884,8 @@ void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem )
|
||||||
if( aItem->Type() == SCH_SHEET_PIN_T || aItem->Type() == SCH_FIELD_T )
|
if( aItem->Type() == SCH_SHEET_PIN_T || aItem->Type() == SCH_FIELD_T )
|
||||||
RefreshItem( aItem );
|
RefreshItem( aItem );
|
||||||
|
|
||||||
// For some items, moving the cursor to anchor is not good
|
// For some items, moving the cursor to anchor is not good (for instance large
|
||||||
// (for instance large hierarchical sheets od componants can have
|
// hierarchical sheets or components can have the anchor outside the view)
|
||||||
// the anchor position outside the canvas)
|
|
||||||
// these items return IsMovableFromAnchorPoint() == false
|
|
||||||
// For these items, do not warp the cursor
|
|
||||||
if( aItem->IsMovableFromAnchorPoint() )
|
if( aItem->IsMovableFromAnchorPoint() )
|
||||||
{
|
{
|
||||||
SetCrossHairPosition( aItem->GetPosition() );
|
SetCrossHairPosition( aItem->GetPosition() );
|
||||||
|
@ -1468,8 +1497,7 @@ void SCH_EDIT_FRAME::OnUnfoldBusHotkey( wxCommandEvent& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bus_unfolding_menu->Append( id, member->Name(),
|
bus_unfolding_menu->Append( id, member->Name(), wxEmptyString );
|
||||||
wxEmptyString );
|
|
||||||
|
|
||||||
// Because Bind() takes ownership of the user data item, we
|
// Because Bind() takes ownership of the user data item, we
|
||||||
// make a new menu item here and set its label. Why create a
|
// make a new menu item here and set its label. Why create a
|
||||||
|
|
|
@ -195,7 +195,7 @@ void SCH_EDIT_FRAME::ReCreateVToolbar()
|
||||||
m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiScaledBitmap( cursor_xpm, this ),
|
m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiScaledBitmap( cursor_xpm, this ),
|
||||||
HELP_SELECT, wxITEM_CHECK );
|
HELP_SELECT, wxITEM_CHECK );
|
||||||
|
|
||||||
m_drawToolBar->AddTool( ID_HIGHLIGHT, wxEmptyString,
|
m_drawToolBar->AddTool( ID_HIGHLIGHT_BUTT, wxEmptyString,
|
||||||
KiScaledBitmap( net_highlight_schematic_xpm, this ),
|
KiScaledBitmap( net_highlight_schematic_xpm, this ),
|
||||||
HELP_HIGHLIGHT, wxITEM_CHECK );
|
HELP_HIGHLIGHT, wxITEM_CHECK );
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,13 @@
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <eeschema_id.h>
|
#include <eeschema_id.h>
|
||||||
|
#include <tool/tool_manager.h>
|
||||||
|
#include <tool/common_tools.h>
|
||||||
|
#include <tools/sch_editor_control.h>
|
||||||
|
#include <tools/sch_picker_tool.h>
|
||||||
|
|
||||||
#include <sch_actions.h>
|
#include <sch_actions.h>
|
||||||
|
|
||||||
|
|
||||||
OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
||||||
{
|
{
|
||||||
switch( aId )
|
switch( aId )
|
||||||
|
@ -66,7 +69,21 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
||||||
|
|
||||||
case ID_POPUP_GRID_PREV:
|
case ID_POPUP_GRID_PREV:
|
||||||
return ACTIONS::gridPrev.MakeEvent();
|
return ACTIONS::gridPrev.MakeEvent();
|
||||||
|
|
||||||
|
case ID_HIGHLIGHT_BUTT:
|
||||||
|
return SCH_ACTIONS::highlightNetCursor.MakeEvent();
|
||||||
|
|
||||||
|
case ID_HIGHLIGHT_NET:
|
||||||
|
return SCH_ACTIONS::highlightNet.MakeEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
return OPT<TOOL_EVENT>();
|
return OPT<TOOL_EVENT>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SCH_ACTIONS::RegisterAllTools( TOOL_MANAGER* aToolManager )
|
||||||
|
{
|
||||||
|
aToolManager->RegisterTool( new COMMON_TOOLS );
|
||||||
|
aToolManager->RegisterTool( new SCH_EDITOR_CONTROL );
|
||||||
|
aToolManager->RegisterTool( new SCH_PICKER_TOOL );
|
||||||
|
}
|
||||||
|
|
|
@ -61,19 +61,6 @@ public:
|
||||||
/// Runs a selection menu to select from a list of items
|
/// Runs a selection menu to select from a list of items
|
||||||
static TOOL_ACTION selectionMenu;
|
static TOOL_ACTION selectionMenu;
|
||||||
|
|
||||||
// Display modes
|
|
||||||
static TOOL_ACTION ratsnestLineMode;
|
|
||||||
static TOOL_ACTION trackDisplayMode;
|
|
||||||
static TOOL_ACTION padDisplayMode;
|
|
||||||
static TOOL_ACTION viaDisplayMode;
|
|
||||||
static TOOL_ACTION graphicDisplayMode;
|
|
||||||
static TOOL_ACTION zoneDisplayEnable;
|
|
||||||
static TOOL_ACTION zoneDisplayDisable;
|
|
||||||
static TOOL_ACTION zoneDisplayOutlines;
|
|
||||||
static TOOL_ACTION highContrastMode;
|
|
||||||
static TOOL_ACTION highContrastInc;
|
|
||||||
static TOOL_ACTION highContrastDec;
|
|
||||||
|
|
||||||
/* Can we share these with PCBNew?
|
/* Can we share these with PCBNew?
|
||||||
// Layer control
|
// Layer control
|
||||||
static TOOL_ACTION layerTop;
|
static TOOL_ACTION layerTop;
|
||||||
|
@ -110,10 +97,11 @@ public:
|
||||||
static TOOL_ACTION switchUnits;
|
static TOOL_ACTION switchUnits;
|
||||||
static TOOL_ACTION updateUnits;
|
static TOOL_ACTION updateUnits;
|
||||||
static TOOL_ACTION deleteItemCursor;
|
static TOOL_ACTION deleteItemCursor;
|
||||||
static TOOL_ACTION clearHighlight;
|
|
||||||
|
// Net highlighting
|
||||||
static TOOL_ACTION highlightNet;
|
static TOOL_ACTION highlightNet;
|
||||||
static TOOL_ACTION highlightNetCursor;
|
|
||||||
static TOOL_ACTION highlightNetSelection;
|
static TOOL_ACTION highlightNetSelection;
|
||||||
|
static TOOL_ACTION highlightNetCursor;
|
||||||
|
|
||||||
///> @copydoc COMMON_ACTIONS::TranslateLegacyId()
|
///> @copydoc COMMON_ACTIONS::TranslateLegacyId()
|
||||||
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override;
|
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override;
|
||||||
|
|
|
@ -0,0 +1,266 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 1992-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 <fctsys.h>
|
||||||
|
#include <sch_view.h>
|
||||||
|
#include <sch_draw_panel.h>
|
||||||
|
#include <sch_edit_frame.h>
|
||||||
|
#include <sch_component.h>
|
||||||
|
#include <sch_sheet.h>
|
||||||
|
#include <erc.h>
|
||||||
|
#include <eeschema_id.h>
|
||||||
|
#include <netlist_object.h>
|
||||||
|
#include <tool/tool_manager.h>
|
||||||
|
#include <tools/sch_actions.h>
|
||||||
|
#include <tools/sch_picker_tool.h>
|
||||||
|
|
||||||
|
#include <tools/sch_editor_control.h>
|
||||||
|
|
||||||
|
|
||||||
|
TOOL_ACTION SCH_ACTIONS::highlightNet( "eeschema.EditorControl.highlightNet",
|
||||||
|
AS_GLOBAL, 0, "", "" );
|
||||||
|
|
||||||
|
TOOL_ACTION SCH_ACTIONS::highlightNetSelection( "eeschema.EditorControl.highlightNetSelection",
|
||||||
|
AS_GLOBAL, 0, "", "" );
|
||||||
|
|
||||||
|
TOOL_ACTION SCH_ACTIONS::highlightNetCursor( "eeschema.EditorControl.highlightNetCursor",
|
||||||
|
AS_GLOBAL, 0, "", "" );
|
||||||
|
|
||||||
|
|
||||||
|
SCH_EDITOR_CONTROL::SCH_EDITOR_CONTROL() :
|
||||||
|
TOOL_INTERACTIVE( "eeschema.EditorControl" ),
|
||||||
|
m_frame( nullptr ),
|
||||||
|
m_menu( *this )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SCH_EDITOR_CONTROL::~SCH_EDITOR_CONTROL()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SCH_EDITOR_CONTROL::Reset( RESET_REASON aReason )
|
||||||
|
{
|
||||||
|
m_frame = getEditFrame<SCH_EDIT_FRAME>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SCH_EDITOR_CONTROL::Init()
|
||||||
|
{
|
||||||
|
auto activeToolCondition = [ this ] ( const SELECTION& aSel ) {
|
||||||
|
return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED );
|
||||||
|
};
|
||||||
|
|
||||||
|
auto inactiveStateCondition = [ this ] ( const SELECTION& aSel ) {
|
||||||
|
return ( m_frame->GetToolId() == ID_NO_TOOL_SELECTED && aSel.Size() == 0 );
|
||||||
|
};
|
||||||
|
|
||||||
|
auto& ctxMenu = m_menu.GetMenu();
|
||||||
|
|
||||||
|
// "Cancel" goes at the top of the context menu when a tool is active
|
||||||
|
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1000 );
|
||||||
|
ctxMenu.AddSeparator( activeToolCondition, 1000 );
|
||||||
|
|
||||||
|
// Finally, add the standard zoom & grid items
|
||||||
|
m_menu.AddStandardSubMenus( *getEditFrame<SCH_BASE_FRAME>() );
|
||||||
|
|
||||||
|
/*
|
||||||
|
auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
|
||||||
|
lockMenu->SetTool( this );
|
||||||
|
|
||||||
|
// Add the SCH control menus to relevant other tools
|
||||||
|
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||||
|
|
||||||
|
if( selTool )
|
||||||
|
{
|
||||||
|
auto& toolMenu = selTool->GetToolMenu();
|
||||||
|
auto& menu = toolMenu.GetMenu();
|
||||||
|
|
||||||
|
menu.AddSeparator( inactiveStateCondition );
|
||||||
|
toolMenu.AddSubMenu( lockMenu );
|
||||||
|
|
||||||
|
menu.AddMenu( lockMenu.get(), false,
|
||||||
|
SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::LockableItems ), 200 );
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
if( editFrame->GetScreen()->GetNode( wxPoint( aPosition.x, aPosition.y ), nodeList ) )
|
||||||
|
{
|
||||||
|
if( TestDuplicateSheetNames( false ) > 0 )
|
||||||
|
{
|
||||||
|
wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet." ) );
|
||||||
|
retVal = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( auto item = dynamic_cast<SCH_ITEM*>( nodeList[0] ) )
|
||||||
|
{
|
||||||
|
if( item->Connection( *g_CurrentSheet ) )
|
||||||
|
{
|
||||||
|
netName = item->Connection( *g_CurrentSheet )->Name();
|
||||||
|
editFrame->SetStatusText( _( "Highlighted net: " ) + UnescapeString( netName ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
editFrame->SetSelectedNetName( netName );
|
||||||
|
editFrame->SendCrossProbeNetName( netName );
|
||||||
|
editFrame->SetStatusText( _( "Selected net: " ) + UnescapeString( netName ) );
|
||||||
|
|
||||||
|
aToolMgr->RunAction( SCH_ACTIONS::highlightNetSelection, true );
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int SCH_EDITOR_CONTROL::HighlightNet( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||||
|
VECTOR2I gridPosition = controls->GetCursorPosition( true );
|
||||||
|
|
||||||
|
highlightNet( m_toolMgr, gridPosition );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int SCH_EDITOR_CONTROL::HighlightNetSelection( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
SCH_SCREEN* screen = g_CurrentSheet->LastScreen();
|
||||||
|
std::vector<EDA_ITEM*> itemsToRedraw;
|
||||||
|
wxString selectedNetName = m_frame->GetSelectedNetName();
|
||||||
|
|
||||||
|
if( !screen )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for( SCH_ITEM* ptr = screen->GetDrawItems(); ptr; ptr = ptr->Next() )
|
||||||
|
{
|
||||||
|
auto conn = ptr->Connection( *g_CurrentSheet );
|
||||||
|
bool redraw = ptr->GetState( BRIGHTENED );
|
||||||
|
|
||||||
|
ptr->SetState( BRIGHTENED, ( conn && conn->Name() == selectedNetName ) );
|
||||||
|
|
||||||
|
redraw |= ptr->GetState( BRIGHTENED );
|
||||||
|
|
||||||
|
if( ptr->Type() == SCH_COMPONENT_T )
|
||||||
|
{
|
||||||
|
SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( ptr );
|
||||||
|
|
||||||
|
redraw |= comp->HasBrightenedPins();
|
||||||
|
|
||||||
|
comp->ClearBrightenedPins();
|
||||||
|
std::vector<LIB_PIN*> pins;
|
||||||
|
comp->GetPins( pins );
|
||||||
|
|
||||||
|
for( LIB_PIN* pin : pins )
|
||||||
|
{
|
||||||
|
auto pin_conn = comp->GetConnectionForPin( pin, *g_CurrentSheet );
|
||||||
|
|
||||||
|
if( pin_conn && pin_conn->Name( false ) == selectedNetName )
|
||||||
|
{
|
||||||
|
comp->BrightenPin( pin );
|
||||||
|
redraw = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( ptr->Type() == SCH_SHEET_T )
|
||||||
|
{
|
||||||
|
for( SCH_SHEET_PIN& pin : static_cast<SCH_SHEET*>( ptr )->GetPins() )
|
||||||
|
{
|
||||||
|
auto pin_conn = pin.Connection( *g_CurrentSheet );
|
||||||
|
bool redrawPin = pin.GetState( BRIGHTENED );
|
||||||
|
|
||||||
|
pin.SetState( BRIGHTENED, ( pin_conn && pin_conn->Name() == selectedNetName ) );
|
||||||
|
|
||||||
|
redrawPin |= pin.GetState( BRIGHTENED );
|
||||||
|
|
||||||
|
if( redrawPin )
|
||||||
|
itemsToRedraw.push_back( &pin );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( redraw )
|
||||||
|
itemsToRedraw.push_back( ptr );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Be sure hightlight change will be redrawn
|
||||||
|
KIGFX::VIEW* view = getView();
|
||||||
|
|
||||||
|
for( auto item : itemsToRedraw )
|
||||||
|
view->Update( (KIGFX::VIEW_ITEM*)item, KIGFX::VIEW_UPDATE_FLAGS::REPAINT );
|
||||||
|
|
||||||
|
m_frame->GetGalCanvas()->Refresh();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
Activate();
|
||||||
|
|
||||||
|
SCH_PICKER_TOOL* picker = m_toolMgr->GetTool<SCH_PICKER_TOOL>();
|
||||||
|
assert( picker );
|
||||||
|
|
||||||
|
m_frame->SetToolID( ID_HIGHLIGHT_BUTT, wxCURSOR_HAND, _( "Highlight net" ) );
|
||||||
|
picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, std::placeholders::_1 ) );
|
||||||
|
picker->Activate();
|
||||||
|
Wait();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SCH_EDITOR_CONTROL::setTransitions()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Go( &SCH_EDITOR_CONTROL::ToggleLockSelected, SCH_ACTIONS::toggleLock.MakeEvent() );
|
||||||
|
Go( &SCH_EDITOR_CONTROL::LockSelected, SCH_ACTIONS::lock.MakeEvent() );
|
||||||
|
Go( &SCH_EDITOR_CONTROL::UnlockSelected, SCH_ACTIONS::unlock.MakeEvent() );
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
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::HighlightNetCursor, SCH_ACTIONS::highlightNetCursor.MakeEvent() );
|
||||||
|
Go( &SCH_EDITOR_CONTROL::HighlightNetSelection, SCH_ACTIONS::highlightNetSelection.MakeEvent() );
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
/*
|
||||||
|
* 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 SCH_EDITOR_CONTROL_H
|
||||||
|
#define SCH_EDITOR_CONTROL_H
|
||||||
|
|
||||||
|
#include <tool/tool_interactive.h>
|
||||||
|
#include <tool/tool_event.h>
|
||||||
|
#include <tool/tool_menu.h>
|
||||||
|
|
||||||
|
class SCH_EDIT_FRAME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class SCH_EDITOR_CONTROL
|
||||||
|
*
|
||||||
|
* Handles actions specific to the schematic editor in eeschema.
|
||||||
|
*/
|
||||||
|
class SCH_EDITOR_CONTROL : public wxEvtHandler, public TOOL_INTERACTIVE
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SCH_EDITOR_CONTROL();
|
||||||
|
~SCH_EDITOR_CONTROL();
|
||||||
|
|
||||||
|
/// @copydoc TOOL_INTERACTIVE::Reset()
|
||||||
|
void Reset( RESET_REASON aReason ) override;
|
||||||
|
|
||||||
|
/// @copydoc TOOL_INTERACTIVE::Init()
|
||||||
|
bool Init() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function PlaceComponent()
|
||||||
|
* Displays a dialog to select a module to be added and allows the user to set its position.
|
||||||
|
*/
|
||||||
|
int PlaceComponent( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
///> Toggles 'lock' property for selected items.
|
||||||
|
int ToggleLockSelected( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
///> Locks selected items.
|
||||||
|
int LockSelected( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
///> Unlocks selected items.
|
||||||
|
int UnlockSelected( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
///> Reacts to selection change in pcbnew.
|
||||||
|
int CrossProbePcbToSch( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
///> Notifies pcbnew about the selected item.
|
||||||
|
int CrossProbeSchToPcb( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
///> Highlights net belonging to the item under the cursor.
|
||||||
|
int HighlightNet( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
///> Highlight all items which match the frame's SelectedNetName.
|
||||||
|
int HighlightNetSelection( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
///> Launches a tool to pick the item whose net is going to be highlighted.
|
||||||
|
int HighlightNetCursor( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
///> Sets up handlers for various events.
|
||||||
|
void setTransitions() override;
|
||||||
|
|
||||||
|
///> Pointer to the currently used edit frame.
|
||||||
|
SCH_EDIT_FRAME* m_frame;
|
||||||
|
|
||||||
|
/// Menu model displayed by the tool.
|
||||||
|
TOOL_MENU m_menu;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // SCH_EDITOR_CONTROL_H
|
|
@ -0,0 +1,157 @@
|
||||||
|
/*
|
||||||
|
* 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_picker_tool.h>
|
||||||
|
#include <sch_actions.h>
|
||||||
|
#include <view/view_controls.h>
|
||||||
|
#include <tool/tool_manager.h>
|
||||||
|
#include <sch_base_frame.h>
|
||||||
|
|
||||||
|
TOOL_ACTION SCH_ACTIONS::pickerTool( "eeschema.Picker", AS_GLOBAL, 0, "", "", NULL, AF_ACTIVATE );
|
||||||
|
|
||||||
|
|
||||||
|
SCH_PICKER_TOOL::SCH_PICKER_TOOL()
|
||||||
|
: TOOL_INTERACTIVE( "eeschema.Picker" )
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int SCH_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||||
|
int finalize_state = WAIT_CANCEL;
|
||||||
|
|
||||||
|
setControls();
|
||||||
|
|
||||||
|
while( OPT_TOOL_EVENT evt = Wait() )
|
||||||
|
{
|
||||||
|
VECTOR2I cursorPos = controls->GetCursorPosition( true );
|
||||||
|
|
||||||
|
if( evt->IsClick( BUT_LEFT ) )
|
||||||
|
{
|
||||||
|
bool getNext = false;
|
||||||
|
|
||||||
|
m_picked = cursorPos;
|
||||||
|
|
||||||
|
if( m_clickHandler )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
getNext = (*m_clickHandler)( *m_picked );
|
||||||
|
}
|
||||||
|
catch( std::exception& e )
|
||||||
|
{
|
||||||
|
std::cerr << "SCH_PICKER_TOOL click handler error: " << e.what() << std::endl;
|
||||||
|
finalize_state = EXCEPTION_CANCEL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !getNext )
|
||||||
|
{
|
||||||
|
finalize_state = CLICK_CANCEL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
setControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if( evt->IsAction( &ACTIONS::cancelInteractive ) || evt->IsActivate() || evt->IsCancel() )
|
||||||
|
{
|
||||||
|
if( m_cancelHandler )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
(*m_cancelHandler)();
|
||||||
|
}
|
||||||
|
catch( std::exception& e )
|
||||||
|
{
|
||||||
|
std::cerr << "SCH_PICKER_TOOL cancel handler error: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activating a new tool may have alternate finalization from canceling the current tool
|
||||||
|
if( evt->IsActivate() )
|
||||||
|
finalize_state = END_ACTIVATE;
|
||||||
|
else
|
||||||
|
finalize_state = EVT_CANCEL;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if( evt->IsClick( BUT_RIGHT ) )
|
||||||
|
{
|
||||||
|
// TODO...
|
||||||
|
// m_menu.ShowContextMenu();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_toolMgr->PassEvent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_finalizeHandler )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
(*m_finalizeHandler)( finalize_state );
|
||||||
|
}
|
||||||
|
catch( std::exception& e )
|
||||||
|
{
|
||||||
|
std::cerr << "SCH_PICKER_TOOL finalize handler error: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reset();
|
||||||
|
controls->ForceCursorPosition( false );
|
||||||
|
getEditFrame<SCH_BASE_FRAME>()->SetNoToolSelected();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SCH_PICKER_TOOL::setTransitions()
|
||||||
|
{
|
||||||
|
Go( &SCH_PICKER_TOOL::Main, SCH_ACTIONS::pickerTool.MakeEvent() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SCH_PICKER_TOOL::reset()
|
||||||
|
{
|
||||||
|
m_cursorCapture = false;
|
||||||
|
m_autoPanning = false;
|
||||||
|
|
||||||
|
m_picked = NULLOPT;
|
||||||
|
m_clickHandler = NULLOPT;
|
||||||
|
m_cancelHandler = NULLOPT;
|
||||||
|
m_finalizeHandler = NULLOPT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SCH_PICKER_TOOL::setControls()
|
||||||
|
{
|
||||||
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||||
|
|
||||||
|
controls->CaptureCursor( m_cursorCapture );
|
||||||
|
controls->SetAutoPan( m_autoPanning );
|
||||||
|
}
|
|
@ -0,0 +1,121 @@
|
||||||
|
/*
|
||||||
|
* 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 SCH_PICKER_TOOL_H
|
||||||
|
#define SCH_PICKER_TOOL_H
|
||||||
|
|
||||||
|
#include <boost/optional/optional.hpp>
|
||||||
|
|
||||||
|
#include <tool/tool_interactive.h>
|
||||||
|
|
||||||
|
|
||||||
|
class SCH_PICKER_TOOL : public TOOL_INTERACTIVE
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SCH_PICKER_TOOL();
|
||||||
|
~SCH_PICKER_TOOL() {}
|
||||||
|
|
||||||
|
///> Event handler types.
|
||||||
|
typedef std::function<bool(const VECTOR2D&)> CLICK_HANDLER;
|
||||||
|
typedef std::function<void(void)> CANCEL_HANDLER;
|
||||||
|
typedef std::function<void(const int&)> FINALIZE_HANDLER;
|
||||||
|
|
||||||
|
enum pickerEndState
|
||||||
|
{
|
||||||
|
WAIT_CANCEL,
|
||||||
|
CLICK_CANCEL,
|
||||||
|
END_ACTIVATE,
|
||||||
|
EVT_CANCEL,
|
||||||
|
EXCEPTION_CANCEL
|
||||||
|
};
|
||||||
|
|
||||||
|
///> @copydoc TOOL_INTERACTIVE::Reset()
|
||||||
|
void Reset( RESET_REASON aReason ) override {}
|
||||||
|
|
||||||
|
///> Main event loop.
|
||||||
|
int Main( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function SetAutoPanning()
|
||||||
|
* Sets autopanning mode for the period when the tool is active.
|
||||||
|
*/
|
||||||
|
inline void SetAutoPanning( bool aEnable ) { m_autoPanning = aEnable; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function SetAutoPanning()
|
||||||
|
* Toggles cursor capture mode for the period when the tool is active.
|
||||||
|
*/
|
||||||
|
inline void SetCursorCapture( bool aEnable ) { m_cursorCapture = aEnable; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function SetClickHandler()
|
||||||
|
* Sets a handler for mouse click event. Handler may decide to receive further click by
|
||||||
|
* returning true.
|
||||||
|
*/
|
||||||
|
inline void SetClickHandler( CLICK_HANDLER aHandler )
|
||||||
|
{
|
||||||
|
assert( !m_clickHandler );
|
||||||
|
m_clickHandler = aHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function SetCancelHandler()
|
||||||
|
* Sets a handler for cancel events (ESC or context-menu Cancel).
|
||||||
|
*/
|
||||||
|
inline void SetCancelHandler( CANCEL_HANDLER aHandler )
|
||||||
|
{
|
||||||
|
assert( !m_cancelHandler );
|
||||||
|
m_cancelHandler = aHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function SetFinalizeHandler()
|
||||||
|
* Sets a handler for the finalize event. Takes the state of the exit from the Main loop
|
||||||
|
*/
|
||||||
|
inline void SetFinalizeHandler( FINALIZE_HANDLER aHandler )
|
||||||
|
{
|
||||||
|
assert( !m_finalizeHandler );
|
||||||
|
m_finalizeHandler = aHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
///> @copydoc TOOL_INTERACTIVE::setTransitions();
|
||||||
|
void setTransitions() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_cursorCapture;
|
||||||
|
bool m_autoPanning;
|
||||||
|
|
||||||
|
OPT<CLICK_HANDLER> m_clickHandler;
|
||||||
|
OPT<CANCEL_HANDLER> m_cancelHandler;
|
||||||
|
OPT<FINALIZE_HANDLER> m_finalizeHandler;
|
||||||
|
|
||||||
|
OPT<VECTOR2D> m_picked;
|
||||||
|
|
||||||
|
///> Reinitializes tool to its initial state.
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
///> Applies the requested VIEW_CONTROLS settings.
|
||||||
|
void setControls();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* SCH_PICKER_TOOL_H */
|
|
@ -0,0 +1,99 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 KiCad Developers, see CHANGELOG.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 <limits>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <tool/selection.h>
|
||||||
|
#include <sch_item_struct.h>
|
||||||
|
|
||||||
|
|
||||||
|
VECTOR2I SELECTION::GetPosition() const
|
||||||
|
{
|
||||||
|
return static_cast<VECTOR2I>( GetBoundingBox().GetPosition() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VECTOR2I SELECTION::GetCenter() const
|
||||||
|
{
|
||||||
|
return static_cast<VECTOR2I>( GetBoundingBox().Centre() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EDA_RECT SELECTION::GetBoundingBox() const
|
||||||
|
{
|
||||||
|
EDA_RECT bbox;
|
||||||
|
|
||||||
|
bbox = Front()->GetBoundingBox();
|
||||||
|
auto i = m_items.begin();
|
||||||
|
++i;
|
||||||
|
|
||||||
|
for( ; i != m_items.end(); ++i )
|
||||||
|
bbox.Merge( (*i)->GetBoundingBox() );
|
||||||
|
|
||||||
|
return bbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EDA_ITEM* SELECTION::GetTopLeftItem( bool onlyModules ) const
|
||||||
|
{
|
||||||
|
SCH_ITEM* topLeftItem = nullptr;
|
||||||
|
SCH_ITEM* currentItem;
|
||||||
|
|
||||||
|
wxPoint pos;
|
||||||
|
|
||||||
|
// find the leftmost (smallest x coord) and highest (smallest y with the smallest x) item in the selection
|
||||||
|
for( auto item : m_items )
|
||||||
|
{
|
||||||
|
currentItem = static_cast<SCH_ITEM*>( item );
|
||||||
|
pos = currentItem->GetPosition();
|
||||||
|
|
||||||
|
if( topLeftItem == nullptr )
|
||||||
|
topLeftItem = currentItem;
|
||||||
|
else if( pos.x < topLeftItem->GetPosition().x )
|
||||||
|
topLeftItem = currentItem;
|
||||||
|
else if( topLeftItem->GetPosition().x == pos.x && pos.y < topLeftItem->GetPosition().y )
|
||||||
|
topLeftItem = currentItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
return static_cast<EDA_ITEM*>( topLeftItem );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const BOX2I SELECTION::ViewBBox() const
|
||||||
|
{
|
||||||
|
BOX2I r;
|
||||||
|
r.SetMaximum();
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const KIGFX::VIEW_GROUP::ITEMS SELECTION::updateDrawList() const
|
||||||
|
{
|
||||||
|
std::vector<VIEW_ITEM*> items;
|
||||||
|
|
||||||
|
for( auto item : m_items )
|
||||||
|
items.push_back( item );
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 <tool/tool_manager.h>
|
|
||||||
#include <tool/common_tools.h>
|
|
||||||
|
|
||||||
#include <tools/sch_actions.h>
|
|
||||||
|
|
||||||
|
|
||||||
void SCH_ACTIONS::RegisterAllTools( TOOL_MANAGER* aToolManager )
|
|
||||||
{
|
|
||||||
aToolManager->RegisterTool( new COMMON_TOOLS );
|
|
||||||
}
|
|
|
@ -343,7 +343,6 @@ set( PCBNEW_CLASS_SRCS
|
||||||
tools/selection.cpp
|
tools/selection.cpp
|
||||||
tools/selection_tool.cpp
|
tools/selection_tool.cpp
|
||||||
tools/tool_event_utils.cpp
|
tools/tool_event_utils.cpp
|
||||||
tools/tools_common.cpp
|
|
||||||
tools/zone_create_helper.cpp
|
tools/zone_create_helper.cpp
|
||||||
tools/zone_filler_tool.cpp
|
tools/zone_filler_tool.cpp
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,25 @@
|
||||||
|
|
||||||
#include "pcb_actions.h"
|
#include "pcb_actions.h"
|
||||||
#include <pcbnew_id.h>
|
#include <pcbnew_id.h>
|
||||||
|
#include <tool/tool_manager.h>
|
||||||
|
#include <tool/common_tools.h>
|
||||||
|
#include <tool/zoom_tool.h>
|
||||||
|
#include <tools/selection_tool.h>
|
||||||
|
#include <tools/picker_tool.h>
|
||||||
|
#include <tools/edit_tool.h>
|
||||||
|
#include <tools/drawing_tool.h>
|
||||||
|
#include <tools/point_editor.h>
|
||||||
|
#include <tools/pcbnew_control.h>
|
||||||
|
#include <tools/pcb_editor_control.h>
|
||||||
|
#include <tools/placement_tool.h>
|
||||||
|
#include <tools/pad_tool.h>
|
||||||
|
#include <tools/microwave_tool.h>
|
||||||
|
#include <tools/position_relative_tool.h>
|
||||||
|
#include <tools/zone_filler_tool.h>
|
||||||
|
#include <tools/pcb_actions.h>
|
||||||
|
#include <router/router_tool.h>
|
||||||
|
#include <router/length_tuner_tool.h>
|
||||||
|
#include <autorouter/autoplacer_tool.h>
|
||||||
|
|
||||||
|
|
||||||
OPT<TOOL_EVENT> PCB_ACTIONS::TranslateLegacyId( int aId )
|
OPT<TOOL_EVENT> PCB_ACTIONS::TranslateLegacyId( int aId )
|
||||||
|
@ -237,3 +256,25 @@ OPT<TOOL_EVENT> PCB_ACTIONS::TranslateLegacyId( int aId )
|
||||||
|
|
||||||
return OPT<TOOL_EVENT>();
|
return OPT<TOOL_EVENT>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_ACTIONS::RegisterAllTools( TOOL_MANAGER* aToolManager )
|
||||||
|
{
|
||||||
|
aToolManager->RegisterTool( new COMMON_TOOLS );
|
||||||
|
aToolManager->RegisterTool( new SELECTION_TOOL );
|
||||||
|
aToolManager->RegisterTool( new ZOOM_TOOL );
|
||||||
|
aToolManager->RegisterTool( new PICKER_TOOL );
|
||||||
|
aToolManager->RegisterTool( new ROUTER_TOOL );
|
||||||
|
aToolManager->RegisterTool( new LENGTH_TUNER_TOOL );
|
||||||
|
aToolManager->RegisterTool( new EDIT_TOOL );
|
||||||
|
aToolManager->RegisterTool( new PAD_TOOL );
|
||||||
|
aToolManager->RegisterTool( new DRAWING_TOOL );
|
||||||
|
aToolManager->RegisterTool( new POINT_EDITOR );
|
||||||
|
aToolManager->RegisterTool( new PCBNEW_CONTROL );
|
||||||
|
aToolManager->RegisterTool( new PCB_EDITOR_CONTROL );
|
||||||
|
aToolManager->RegisterTool( new ALIGN_DISTRIBUTE_TOOL );
|
||||||
|
aToolManager->RegisterTool( new MICROWAVE_TOOL );
|
||||||
|
aToolManager->RegisterTool( new POSITION_RELATIVE_TOOL );
|
||||||
|
aToolManager->RegisterTool( new ZONE_FILLER_TOOL );
|
||||||
|
aToolManager->RegisterTool( new AUTOPLACE_TOOL );
|
||||||
|
}
|
||||||
|
|
|
@ -1172,7 +1172,6 @@ int PCB_EDITOR_CONTROL::ShowLocalRatsnest( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
picker->SetSnapping( false );
|
|
||||||
picker->Activate();
|
picker->Activate();
|
||||||
Wait();
|
Wait();
|
||||||
|
|
||||||
|
|
|
@ -698,7 +698,6 @@ int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_frame->SetToolID( m_editModules ? ID_MODEDIT_DELETE_TOOL : ID_PCB_DELETE_ITEM_BUTT,
|
m_frame->SetToolID( m_editModules ? ID_MODEDIT_DELETE_TOOL : ID_PCB_DELETE_ITEM_BUTT,
|
||||||
wxCURSOR_BULLSEYE, _( "Delete item" ) );
|
wxCURSOR_BULLSEYE, _( "Delete item" ) );
|
||||||
picker->SetSnapping( false );
|
|
||||||
picker->SetClickHandler( std::bind( deleteItem, m_toolMgr, _1 ) );
|
picker->SetClickHandler( std::bind( deleteItem, m_toolMgr, _1 ) );
|
||||||
picker->Activate();
|
picker->Activate();
|
||||||
Wait();
|
Wait();
|
||||||
|
|
|
@ -143,8 +143,6 @@ void PICKER_TOOL::setTransitions()
|
||||||
|
|
||||||
void PICKER_TOOL::reset()
|
void PICKER_TOOL::reset()
|
||||||
{
|
{
|
||||||
m_cursorSnapping = true;
|
|
||||||
m_cursorVisible = true;
|
|
||||||
m_cursorCapture = false;
|
m_cursorCapture = false;
|
||||||
m_autoPanning = false;
|
m_autoPanning = false;
|
||||||
m_layerMask = LSET::AllLayersMask();
|
m_layerMask = LSET::AllLayersMask();
|
||||||
|
@ -163,7 +161,6 @@ void PICKER_TOOL::setControls()
|
||||||
// Ensure that the view controls do not handle our snapping as we use the GRID_HELPER
|
// Ensure that the view controls do not handle our snapping as we use the GRID_HELPER
|
||||||
controls->SetSnapping( false );
|
controls->SetSnapping( false );
|
||||||
|
|
||||||
controls->ShowCursor( m_cursorVisible );
|
|
||||||
controls->CaptureCursor( m_cursorCapture );
|
controls->CaptureCursor( m_cursorCapture );
|
||||||
controls->SetAutoPan( m_autoPanning );
|
controls->SetAutoPan( m_autoPanning );
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,18 +57,6 @@ public:
|
||||||
///> Main event loop.
|
///> Main event loop.
|
||||||
int Main( const TOOL_EVENT& aEvent );
|
int Main( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
/**
|
|
||||||
* Function SetSnapping()
|
|
||||||
* Sets cursor snapping to grid for the period when the tool is active.
|
|
||||||
*/
|
|
||||||
inline void SetSnapping( bool aEnable ) { m_cursorSnapping = aEnable; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function SetCursorVisible()
|
|
||||||
* Sets cursor visibility for the period when the tool is active.
|
|
||||||
*/
|
|
||||||
inline void SetCursorVisible( bool aEnable ) { m_cursorVisible = aEnable; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SetAutoPanning()
|
* Function SetAutoPanning()
|
||||||
* Sets autopanning mode for the period when the tool is active.
|
* Sets autopanning mode for the period when the tool is active.
|
||||||
|
@ -122,25 +110,18 @@ public:
|
||||||
void setTransitions() override;
|
void setTransitions() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Tool settings.
|
|
||||||
bool m_cursorSnapping;
|
|
||||||
bool m_cursorVisible;
|
|
||||||
bool m_cursorCapture;
|
bool m_cursorCapture;
|
||||||
bool m_autoPanning;
|
bool m_autoPanning;
|
||||||
|
|
||||||
///> The layer set to use for optional snapping
|
///> The layer set to use for optional snapping
|
||||||
LSET m_layerMask;
|
LSET m_layerMask;
|
||||||
|
|
||||||
///> Optional event handlers.
|
|
||||||
OPT<CLICK_HANDLER> m_clickHandler;
|
OPT<CLICK_HANDLER> m_clickHandler;
|
||||||
OPT<CANCEL_HANDLER> m_cancelHandler;
|
OPT<CANCEL_HANDLER> m_cancelHandler;
|
||||||
|
|
||||||
///> Picked point (if any).
|
|
||||||
OPT<VECTOR2D> m_picked;
|
|
||||||
|
|
||||||
///> Optional finalize state handler.
|
|
||||||
OPT<FINALIZE_HANDLER> m_finalizeHandler;
|
OPT<FINALIZE_HANDLER> m_finalizeHandler;
|
||||||
|
|
||||||
|
OPT<VECTOR2D> m_picked;
|
||||||
|
|
||||||
///> Reinitializes tool to its initial state.
|
///> Reinitializes tool to its initial state.
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015 CERN
|
|
||||||
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
|
|
||||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
||||||
*
|
|
||||||
* 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 <io_mgr.h>
|
|
||||||
|
|
||||||
#include <tool/tool_manager.h>
|
|
||||||
#include <tool/common_tools.h>
|
|
||||||
#include <tool/zoom_tool.h>
|
|
||||||
|
|
||||||
#include <tools/selection_tool.h>
|
|
||||||
#include <tools/picker_tool.h>
|
|
||||||
#include <tools/edit_tool.h>
|
|
||||||
#include <tools/drawing_tool.h>
|
|
||||||
#include <tools/point_editor.h>
|
|
||||||
#include <tools/pcbnew_control.h>
|
|
||||||
#include <tools/pcb_editor_control.h>
|
|
||||||
#include <tools/placement_tool.h>
|
|
||||||
#include <tools/pad_tool.h>
|
|
||||||
#include <tools/microwave_tool.h>
|
|
||||||
#include <tools/position_relative_tool.h>
|
|
||||||
#include <tools/zone_filler_tool.h>
|
|
||||||
#include <tools/pcb_actions.h>
|
|
||||||
|
|
||||||
#include <router/router_tool.h>
|
|
||||||
#include <router/length_tuner_tool.h>
|
|
||||||
#include <autorouter/autoplacer_tool.h>
|
|
||||||
|
|
||||||
void PCB_ACTIONS::RegisterAllTools( TOOL_MANAGER* aToolManager )
|
|
||||||
{
|
|
||||||
aToolManager->RegisterTool( new COMMON_TOOLS );
|
|
||||||
aToolManager->RegisterTool( new SELECTION_TOOL );
|
|
||||||
aToolManager->RegisterTool( new ZOOM_TOOL );
|
|
||||||
aToolManager->RegisterTool( new PICKER_TOOL );
|
|
||||||
aToolManager->RegisterTool( new ROUTER_TOOL );
|
|
||||||
aToolManager->RegisterTool( new LENGTH_TUNER_TOOL );
|
|
||||||
aToolManager->RegisterTool( new EDIT_TOOL );
|
|
||||||
aToolManager->RegisterTool( new PAD_TOOL );
|
|
||||||
aToolManager->RegisterTool( new DRAWING_TOOL );
|
|
||||||
aToolManager->RegisterTool( new POINT_EDITOR );
|
|
||||||
aToolManager->RegisterTool( new PCBNEW_CONTROL );
|
|
||||||
aToolManager->RegisterTool( new PCB_EDITOR_CONTROL );
|
|
||||||
aToolManager->RegisterTool( new ALIGN_DISTRIBUTE_TOOL );
|
|
||||||
aToolManager->RegisterTool( new MICROWAVE_TOOL );
|
|
||||||
aToolManager->RegisterTool( new POSITION_RELATIVE_TOOL );
|
|
||||||
aToolManager->RegisterTool( new ZONE_FILLER_TOOL );
|
|
||||||
aToolManager->RegisterTool( new AUTOPLACE_TOOL );
|
|
||||||
}
|
|
Loading…
Reference in New Issue