2019-04-14 00:44:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-08-14 08:28:07 +00:00
|
|
|
* Copyright (C) 2019 CERN
|
2019-04-14 00:44:05 +00:00
|
|
|
* 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>
|
2019-04-23 17:12:26 +00:00
|
|
|
#include <kiway.h>
|
2019-04-14 00:44:05 +00:00
|
|
|
#include <sch_view.h>
|
|
|
|
#include <sch_edit_frame.h>
|
|
|
|
#include <sch_sheet.h>
|
2019-08-12 14:42:11 +00:00
|
|
|
#include <sch_line.h>
|
2019-04-29 21:44:49 +00:00
|
|
|
#include <connection_graph.h>
|
2019-04-14 00:44:05 +00:00
|
|
|
#include <erc.h>
|
|
|
|
#include <eeschema_id.h>
|
|
|
|
#include <netlist_object.h>
|
|
|
|
#include <tool/tool_manager.h>
|
2019-07-15 23:44:01 +00:00
|
|
|
#include <tool/picker_tool.h>
|
2019-05-10 17:19:48 +00:00
|
|
|
#include <tools/ee_actions.h>
|
2019-04-14 00:44:05 +00:00
|
|
|
#include <tools/sch_editor_control.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tools/ee_selection.h>
|
2019-05-10 17:19:48 +00:00
|
|
|
#include <tools/ee_selection_tool.h>
|
2019-04-15 23:56:41 +00:00
|
|
|
#include <advanced_config.h>
|
2019-04-23 17:12:26 +00:00
|
|
|
#include <simulation_cursors.h>
|
|
|
|
#include <sim/sim_plot_frame.h>
|
2019-04-28 16:36:31 +00:00
|
|
|
#include <sch_legacy_plugin.h>
|
|
|
|
#include <class_library.h>
|
|
|
|
#include <confirm.h>
|
2019-05-13 20:42:40 +00:00
|
|
|
#include <sch_painter.h>
|
2019-05-19 21:04:04 +00:00
|
|
|
#include <status_popup.h>
|
2019-05-26 15:36:40 +00:00
|
|
|
#include <ws_proxy_undo_item.h>
|
|
|
|
#include <dialogs/dialog_page_settings.h>
|
2019-06-01 15:28:39 +00:00
|
|
|
#include <dialogs/dialog_fields_editor_global.h>
|
|
|
|
#include <invoke_sch_dialog.h>
|
2019-09-02 18:23:46 +00:00
|
|
|
#include <dialogs/dialog_paste_special.h>
|
2019-04-14 00:44:05 +00:00
|
|
|
|
2019-05-24 23:36:31 +00:00
|
|
|
int SCH_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->NewProject();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::Open( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->LoadProject();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::Save( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-08-28 03:19:20 +00:00
|
|
|
m_frame->SaveProject();
|
2019-05-24 23:36:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::SaveAs( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->Save_File( true );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::PageSetup( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-05-26 15:36:40 +00:00
|
|
|
PICKED_ITEMS_LIST undoCmd;
|
|
|
|
WS_PROXY_UNDO_ITEM* undoItem = new WS_PROXY_UNDO_ITEM( m_frame );
|
|
|
|
ITEM_PICKER wrapper( undoItem, UR_PAGESETTINGS );
|
|
|
|
|
|
|
|
undoCmd.PushItem( wrapper );
|
|
|
|
m_frame->SaveCopyInUndoList( undoCmd, UR_PAGESETTINGS );
|
|
|
|
|
|
|
|
DIALOG_PAGES_SETTINGS dlg( m_frame, wxSize( MAX_PAGE_SIZE_MILS, MAX_PAGE_SIZE_MILS ) );
|
|
|
|
dlg.SetWksFileName( BASE_SCREEN::m_PageLayoutDescrFileName );
|
|
|
|
|
2019-07-07 23:05:59 +00:00
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
2019-05-26 15:36:40 +00:00
|
|
|
m_frame->RollbackSchematicFromUndo();
|
|
|
|
|
2019-05-24 23:36:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::Print( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->Print();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::Plot( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->PlotSchematic();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::Quit( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->Close( false );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
// A dummy wxFindReplaceData signalling any marker should be found
|
|
|
|
static wxFindReplaceData g_markersOnly;
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::FindAndReplace( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->ShowFindReplaceDialog( aEvent.IsAction( &ACTIONS::findAndReplace ));
|
|
|
|
return UpdateFind( aEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::UpdateFind( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
wxFindReplaceData* data = m_frame->GetFindReplaceData();
|
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
|
|
|
|
|| aEvent.IsAction( &ACTIONS::updateFind ) )
|
2019-05-19 21:04:04 +00:00
|
|
|
{
|
|
|
|
m_selectionTool->ClearSelection();
|
|
|
|
|
|
|
|
INSPECTOR_FUNC inspector = [&] ( EDA_ITEM* item, void* )
|
|
|
|
{
|
|
|
|
if( data && item->Matches( *data, nullptr ) )
|
|
|
|
m_selectionTool->BrightenItem( item );
|
|
|
|
else if( item->IsBrightened() )
|
|
|
|
m_selectionTool->UnbrightenItem( item );
|
|
|
|
|
|
|
|
return SEARCH_CONTINUE;
|
|
|
|
};
|
|
|
|
|
|
|
|
EDA_ITEM* start = m_frame->GetScreen()->GetDrawItems();
|
|
|
|
EDA_ITEM::IterateForward( start, inspector, nullptr, EE_COLLECTOR::AllItems );
|
|
|
|
}
|
|
|
|
else if( aEvent.Matches( EVENTS::SelectedItemsModified ) )
|
|
|
|
{
|
|
|
|
for( EDA_ITEM* item : m_selectionTool->GetSelection() )
|
|
|
|
{
|
|
|
|
if( data && item->Matches( *data, nullptr ) )
|
|
|
|
m_selectionTool->BrightenItem( item );
|
|
|
|
else if( item->IsBrightened() )
|
|
|
|
m_selectionTool->UnbrightenItem( item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getView()->UpdateItems();
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EDA_ITEM* nextMatch( SCH_SCREEN* aScreen, EDA_ITEM* after, wxFindReplaceData* data )
|
|
|
|
{
|
|
|
|
EDA_ITEM* found = nullptr;
|
|
|
|
|
|
|
|
INSPECTOR_FUNC inspector = [&] ( EDA_ITEM* item, void* testData )
|
|
|
|
{
|
|
|
|
if( after )
|
|
|
|
{
|
|
|
|
if( after == item )
|
|
|
|
after = nullptr;
|
|
|
|
|
|
|
|
return SEARCH_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ( data == &g_markersOnly && item->Type() == SCH_MARKER_T )
|
|
|
|
|| item->Matches( *data, nullptr ) )
|
|
|
|
{
|
|
|
|
found = item;
|
|
|
|
return SEARCH_QUIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return SEARCH_CONTINUE;
|
|
|
|
};
|
|
|
|
|
|
|
|
EDA_ITEM::IterateForward( aScreen->GetDrawItems(), inspector, nullptr, EE_COLLECTOR::AllItems );
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::FindNext( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-05-23 09:41:06 +00:00
|
|
|
// A timer during which a subsequent FindNext will result in a wrap-around
|
|
|
|
static wxTimer wrapAroundTimer;
|
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
wxFindReplaceData* data = m_frame->GetFindReplaceData();
|
|
|
|
|
|
|
|
if( aEvent.IsAction( &ACTIONS::findNextMarker ) )
|
|
|
|
{
|
|
|
|
if( data )
|
|
|
|
g_markersOnly.SetFlags( data->GetFlags() );
|
|
|
|
|
|
|
|
data = &g_markersOnly;
|
|
|
|
}
|
|
|
|
else if( !data )
|
|
|
|
{
|
|
|
|
return FindAndReplace( ACTIONS::find.MakeEvent() );
|
|
|
|
}
|
|
|
|
|
2019-06-08 21:48:22 +00:00
|
|
|
bool searchAllSheets = !( data->GetFlags() & FR_CURRENT_SHEET_ONLY );
|
|
|
|
EE_SELECTION& selection = m_selectionTool->GetSelection();
|
|
|
|
SCH_SCREEN* afterScreen = m_frame->GetScreen();
|
|
|
|
EDA_ITEM* afterItem = selection.Front();
|
|
|
|
EDA_ITEM* item = nullptr;
|
2019-05-19 21:04:04 +00:00
|
|
|
|
2019-05-23 09:41:06 +00:00
|
|
|
if( wrapAroundTimer.IsRunning() )
|
2019-05-19 21:04:04 +00:00
|
|
|
{
|
|
|
|
afterScreen = nullptr;
|
|
|
|
afterItem = nullptr;
|
2019-05-23 09:41:06 +00:00
|
|
|
wrapAroundTimer.Stop();
|
2019-05-19 21:04:04 +00:00
|
|
|
m_frame->ClearFindReplaceStatus();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_selectionTool->ClearSelection();
|
|
|
|
|
|
|
|
if( afterScreen || !searchAllSheets )
|
|
|
|
item = nextMatch( m_frame->GetScreen(), afterItem, data );
|
|
|
|
|
|
|
|
if( !item && searchAllSheets )
|
|
|
|
{
|
|
|
|
SCH_SHEET_LIST schematic( g_RootSheet );
|
|
|
|
SCH_SCREENS screens;
|
|
|
|
|
|
|
|
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
|
|
|
{
|
|
|
|
if( afterScreen )
|
|
|
|
{
|
|
|
|
if( afterScreen == screen )
|
|
|
|
afterScreen = nullptr;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
item = nextMatch( screen, nullptr, data );
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
{
|
|
|
|
SCH_SHEET_PATH* sheet = schematic.FindSheetForScreen( screen );
|
|
|
|
wxCHECK_MSG( sheet, 0, "Sheet not found for " + screen->GetFileName() );
|
|
|
|
|
|
|
|
*g_CurrentSheet = *sheet;
|
|
|
|
g_CurrentSheet->UpdateAllScreenReferences();
|
|
|
|
|
|
|
|
screen->SetZoom( m_frame->GetScreen()->GetZoom() );
|
|
|
|
screen->TestDanglingEnds();
|
|
|
|
|
|
|
|
m_frame->SetScreen( screen );
|
|
|
|
UpdateFind( ACTIONS::updateFind.MakeEvent() );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
{
|
|
|
|
m_selectionTool->AddItemToSel( item );
|
2019-07-20 00:40:26 +00:00
|
|
|
m_frame->FocusOnLocation( item->GetBoundingBox().GetCenter(), true );
|
2019-05-19 21:04:04 +00:00
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-07-15 23:44:01 +00:00
|
|
|
wxString msg = searchAllSheets ? _( "Reached end of schematic." )
|
|
|
|
: _( "Reached end of sheet." );
|
2019-05-19 21:04:04 +00:00
|
|
|
|
|
|
|
m_frame->ShowFindReplaceStatus( msg + _( "\nFind again to wrap around to the start." ) );
|
2019-05-23 09:41:06 +00:00
|
|
|
wrapAroundTimer.StartOnce( 4000 );
|
2019-05-19 21:04:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_EDITOR_CONTROL::HasMatch()
|
|
|
|
{
|
|
|
|
wxFindReplaceData* data = m_frame->GetFindReplaceData();
|
|
|
|
EDA_ITEM* item = m_selectionTool->GetSelection().Front();
|
|
|
|
|
|
|
|
return data && item && item->Matches( *data, nullptr );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::ReplaceAndFindNext( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
wxFindReplaceData* data = m_frame->GetFindReplaceData();
|
|
|
|
EDA_ITEM* item = m_selectionTool->GetSelection().Front();
|
|
|
|
|
|
|
|
if( !data )
|
|
|
|
return FindAndReplace( ACTIONS::find.MakeEvent() );
|
|
|
|
|
|
|
|
if( item && item->Matches( *data, nullptr ) )
|
|
|
|
{
|
|
|
|
item->Replace( *data, g_CurrentSheet );
|
|
|
|
FindNext( ACTIONS::findNext.MakeEvent() );
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::ReplaceAll( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
wxFindReplaceData* data = m_frame->GetFindReplaceData();
|
|
|
|
|
|
|
|
if( !data )
|
|
|
|
return FindAndReplace( ACTIONS::find.MakeEvent() );
|
|
|
|
|
|
|
|
SCH_SHEET_LIST schematic( g_RootSheet );
|
|
|
|
SCH_SCREENS screens;
|
|
|
|
|
|
|
|
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
|
|
|
{
|
2019-07-15 23:44:01 +00:00
|
|
|
for( EDA_ITEM* item = nextMatch( screen, nullptr, data ); item;
|
2019-05-19 21:04:04 +00:00
|
|
|
item = nextMatch( screen, item, data ) )
|
|
|
|
{
|
|
|
|
item->Replace( *data, schematic.FindSheetForScreen( screen ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-30 18:36:11 +00:00
|
|
|
int SCH_EDITOR_CONTROL::CrossProbeToPcb( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
doCrossProbeSchToPcb( aEvent, false );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::ExplicitCrossProbeToPcb( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
doCrossProbeSchToPcb( aEvent, true );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce )
|
2019-04-21 23:45:34 +00:00
|
|
|
{
|
|
|
|
// Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
|
2019-07-17 20:21:22 +00:00
|
|
|
if( m_probingPcbToSch )
|
2019-04-30 18:36:11 +00:00
|
|
|
return;
|
2019-04-21 23:45:34 +00:00
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
SCH_ITEM* item = nullptr;
|
|
|
|
SCH_COMPONENT* component = nullptr;
|
2019-04-21 23:45:34 +00:00
|
|
|
|
2019-04-30 18:36:11 +00:00
|
|
|
if( aForce )
|
2019-04-21 23:45:34 +00:00
|
|
|
{
|
2019-06-08 21:48:22 +00:00
|
|
|
EE_SELECTION& selection = selTool->RequestSelection();
|
2019-04-21 23:45:34 +00:00
|
|
|
|
2019-04-30 18:36:11 +00:00
|
|
|
if( selection.GetSize() >= 1 )
|
|
|
|
item = (SCH_ITEM*) selection.Front();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-06-08 21:48:22 +00:00
|
|
|
EE_SELECTION& selection = selTool->GetSelection();
|
2019-04-21 23:45:34 +00:00
|
|
|
|
2019-04-30 18:36:11 +00:00
|
|
|
if( selection.GetSize() >= 1 )
|
|
|
|
item = (SCH_ITEM*) selection.Front();
|
|
|
|
}
|
2019-04-21 23:45:34 +00:00
|
|
|
|
2019-04-30 18:36:11 +00:00
|
|
|
if( !item )
|
|
|
|
{
|
|
|
|
if( aForce )
|
|
|
|
m_frame->SendMessageToPCBNEW( nullptr, nullptr );
|
2019-04-21 23:45:34 +00:00
|
|
|
|
2019-04-30 18:36:11 +00:00
|
|
|
return;
|
2019-04-21 23:45:34 +00:00
|
|
|
}
|
|
|
|
|
2019-04-30 18:36:11 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
case SCH_SHEET_T:
|
|
|
|
if( aForce )
|
|
|
|
m_frame->SendMessageToPCBNEW( item, nullptr );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2019-04-21 23:45:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-23 17:12:26 +00:00
|
|
|
#ifdef KICAD_SPICE
|
2019-08-05 06:47:38 +00:00
|
|
|
|
2019-08-05 22:34:47 +00:00
|
|
|
static KICAD_T wires[] = { SCH_LINE_LOCATE_WIRE_T, EOT };
|
|
|
|
static KICAD_T wiresAndPins[] = { SCH_LINE_LOCATE_WIRE_T, SCH_PIN_T, SCH_SHEET_PIN_T, EOT };
|
2019-08-05 06:47:38 +00:00
|
|
|
static KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T, EOT };
|
|
|
|
|
|
|
|
#define HITTEST_THRESHOLD_PIXELS 5
|
|
|
|
|
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
|
2019-04-23 17:12:26 +00:00
|
|
|
{
|
2019-08-05 22:34:47 +00:00
|
|
|
auto picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
|
|
|
auto simFrame = (SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false );
|
|
|
|
|
|
|
|
if( !simFrame ) // Defensive coding; shouldn't happen.
|
|
|
|
return 0;
|
2019-04-23 17:12:26 +00:00
|
|
|
|
2019-07-19 20:47:33 +00:00
|
|
|
// Deactivate other tools; particularly important if another PICKER is currently running
|
|
|
|
Activate();
|
|
|
|
|
2019-08-05 22:34:47 +00:00
|
|
|
picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::VOLTAGE_PROBE ) );
|
2019-04-23 17:12:26 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
picker->SetClickHandler(
|
2019-08-05 22:34:47 +00:00
|
|
|
[this, simFrame] ( const VECTOR2D& aPosition )
|
2019-04-23 17:12:26 +00:00
|
|
|
{
|
2019-07-16 14:11:50 +00:00
|
|
|
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
2019-08-05 06:47:38 +00:00
|
|
|
EDA_ITEM* item = selTool->SelectPoint( aPosition, wiresAndPins );
|
2019-04-23 17:12:26 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
if( !item )
|
|
|
|
return false;
|
2019-04-23 17:12:26 +00:00
|
|
|
|
2019-08-05 22:34:47 +00:00
|
|
|
if( item->IsType( wires ) )
|
2019-07-15 23:44:01 +00:00
|
|
|
{
|
2019-08-05 22:34:47 +00:00
|
|
|
std::unique_ptr<NETLIST_OBJECT_LIST> netlist( m_frame->BuildNetListBase() );
|
2019-07-19 08:12:54 +00:00
|
|
|
|
2019-08-05 22:34:47 +00:00
|
|
|
for( NETLIST_OBJECT* obj : *netlist )
|
|
|
|
{
|
|
|
|
if( obj->m_Comp == item )
|
|
|
|
{
|
2019-08-05 06:47:38 +00:00
|
|
|
simFrame->AddVoltagePlot( UnescapeString( obj->GetNetName() ) );
|
2019-08-05 22:34:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-07-15 23:44:01 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-05 22:34:47 +00:00
|
|
|
else if( item->Type() == SCH_PIN_T )
|
|
|
|
{
|
|
|
|
SCH_PIN* pin = (SCH_PIN*) item;
|
|
|
|
SCH_COMPONENT* comp = (SCH_COMPONENT*) item->GetParent();
|
|
|
|
wxString param = wxString::Format( _T( "I%s" ), pin->GetName().Lower() );
|
|
|
|
|
|
|
|
simFrame->AddCurrentPlot( comp->GetRef( g_CurrentSheet ), param );
|
|
|
|
}
|
2019-04-23 17:12:26 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
return true;
|
|
|
|
} );
|
2019-04-23 17:12:26 +00:00
|
|
|
|
2019-08-05 06:47:38 +00:00
|
|
|
picker->SetMotionHandler(
|
2019-08-05 22:34:47 +00:00
|
|
|
[this, picker] ( const VECTOR2D& aPos )
|
2019-08-05 06:47:38 +00:00
|
|
|
{
|
|
|
|
EE_COLLECTOR collector;
|
|
|
|
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
|
|
|
collector.Collect( m_frame->GetScreen()->GetDrawItems(), wiresAndPins, (wxPoint) aPos );
|
|
|
|
|
|
|
|
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
selectionTool->GuessSelectionCandidates( collector, aPos );
|
|
|
|
|
|
|
|
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
2019-08-12 14:42:11 +00:00
|
|
|
SCH_LINE* wire = dynamic_cast<SCH_LINE*>( item );
|
|
|
|
wxString netName;
|
|
|
|
|
|
|
|
if( wire )
|
|
|
|
{
|
|
|
|
item = nullptr;
|
|
|
|
|
|
|
|
if( wire->Connection( *g_CurrentSheet ) )
|
|
|
|
netName = wire->Connection( *g_CurrentSheet )->Name();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item && item->Type() == SCH_PIN_T )
|
|
|
|
picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::CURRENT_PROBE ) );
|
|
|
|
else
|
|
|
|
picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::VOLTAGE_PROBE ) );
|
2019-08-05 06:47:38 +00:00
|
|
|
|
|
|
|
if( m_pickerItem != item )
|
|
|
|
{
|
2019-08-05 22:34:47 +00:00
|
|
|
|
2019-08-05 06:47:38 +00:00
|
|
|
if( m_pickerItem )
|
|
|
|
selectionTool->UnbrightenItem( m_pickerItem );
|
|
|
|
|
|
|
|
m_pickerItem = item;
|
|
|
|
|
|
|
|
if( m_pickerItem )
|
|
|
|
selectionTool->BrightenItem( m_pickerItem );
|
|
|
|
}
|
2019-08-12 14:42:11 +00:00
|
|
|
|
|
|
|
if( m_frame->GetSelectedNetName() != netName )
|
|
|
|
{
|
|
|
|
m_frame->SetSelectedNetName( netName );
|
|
|
|
|
|
|
|
TOOL_EVENT dummyEvent;
|
|
|
|
UpdateNetHighlighting( dummyEvent );
|
|
|
|
}
|
2019-08-05 06:47:38 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
picker->SetFinalizeHandler(
|
|
|
|
[this] ( const int& aFinalState )
|
|
|
|
{
|
|
|
|
if( m_pickerItem )
|
|
|
|
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
2019-08-12 14:42:11 +00:00
|
|
|
|
|
|
|
if( !m_frame->GetSelectedNetName().IsEmpty() )
|
|
|
|
{
|
|
|
|
m_frame->SetSelectedNetName( wxEmptyString );
|
|
|
|
|
|
|
|
TOOL_EVENT dummyEvent;
|
|
|
|
UpdateNetHighlighting( dummyEvent );
|
|
|
|
}
|
2019-08-05 06:47:38 +00:00
|
|
|
} );
|
|
|
|
|
2019-07-22 01:06:06 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
2019-07-15 23:44:01 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
2019-07-15 12:15:58 +00:00
|
|
|
|
2019-04-23 17:12:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
|
2019-04-23 17:12:26 +00:00
|
|
|
{
|
2019-07-22 01:06:06 +00:00
|
|
|
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
2019-04-23 17:12:26 +00:00
|
|
|
|
2019-07-19 20:47:33 +00:00
|
|
|
// Deactivate other tools; particularly important if another PICKER is currently running
|
|
|
|
Activate();
|
|
|
|
|
2019-08-05 22:34:47 +00:00
|
|
|
picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::CURSOR::TUNE ) );
|
2019-04-23 17:12:26 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
picker->SetClickHandler(
|
2019-07-22 01:06:06 +00:00
|
|
|
[this] ( const VECTOR2D& aPosition )
|
2019-07-15 23:44:01 +00:00
|
|
|
{
|
|
|
|
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
EDA_ITEM* item = selTool->SelectPoint( aPosition, fieldsAndComponents );
|
2019-04-23 17:12:26 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
if( !item )
|
|
|
|
return false;
|
2019-04-23 17:12:26 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
if( item->Type() != SCH_COMPONENT_T )
|
|
|
|
{
|
|
|
|
item = item->GetParent();
|
2019-04-23 17:12:26 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
if( item->Type() != SCH_COMPONENT_T )
|
|
|
|
return false;
|
|
|
|
}
|
2019-04-23 17:12:26 +00:00
|
|
|
|
2019-08-05 06:47:38 +00:00
|
|
|
SIM_PLOT_FRAME* simFrame =
|
|
|
|
(SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false );
|
2019-07-19 08:12:54 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
if( simFrame )
|
|
|
|
simFrame->AddTuner( static_cast<SCH_COMPONENT*>( item ) );
|
2019-04-23 17:12:26 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
return true;
|
|
|
|
} );
|
2019-04-23 17:12:26 +00:00
|
|
|
|
2019-08-05 06:47:38 +00:00
|
|
|
picker->SetMotionHandler(
|
|
|
|
[this] ( const VECTOR2D& aPos )
|
|
|
|
{
|
|
|
|
EE_COLLECTOR collector;
|
|
|
|
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
|
|
|
collector.Collect( m_frame->GetScreen()->GetDrawItems(), fieldsAndComponents, (wxPoint) aPos );
|
|
|
|
|
|
|
|
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
selectionTool->GuessSelectionCandidates( collector, aPos );
|
|
|
|
|
|
|
|
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
|
|
|
|
|
|
|
if( m_pickerItem != item )
|
|
|
|
{
|
|
|
|
if( m_pickerItem )
|
|
|
|
selectionTool->UnbrightenItem( m_pickerItem );
|
|
|
|
|
|
|
|
m_pickerItem = item;
|
|
|
|
|
|
|
|
if( m_pickerItem )
|
|
|
|
selectionTool->BrightenItem( m_pickerItem );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
picker->SetFinalizeHandler(
|
|
|
|
[this] ( const int& aFinalState )
|
|
|
|
{
|
|
|
|
if( m_pickerItem )
|
|
|
|
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
|
|
|
} );
|
|
|
|
|
2019-07-19 08:12:54 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
2019-07-15 23:44:01 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
2019-07-15 12:15:58 +00:00
|
|
|
|
2019-04-23 17:12:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* KICAD_SPICE */
|
|
|
|
|
|
|
|
|
2019-04-30 13:54:32 +00:00
|
|
|
// A singleton reference for clearing the highlight
|
2019-04-21 23:45:34 +00:00
|
|
|
static VECTOR2D CLEAR;
|
|
|
|
|
|
|
|
|
2019-04-14 00:44:05 +00:00
|
|
|
// TODO(JE) Probably use netcode rather than connection name here eventually
|
|
|
|
static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
|
|
|
|
{
|
2019-05-10 23:13:40 +00:00
|
|
|
SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
|
|
|
|
EE_SELECTION_TOOL* selTool = aToolMgr->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
SCH_EDITOR_CONTROL* editorControl = aToolMgr->GetTool<SCH_EDITOR_CONTROL>();
|
|
|
|
wxString netName;
|
|
|
|
bool retVal = true;
|
2019-04-14 00:44:05 +00:00
|
|
|
|
2019-04-30 13:54:32 +00:00
|
|
|
if( aPosition != CLEAR )
|
2019-04-14 00:44:05 +00:00
|
|
|
{
|
|
|
|
if( TestDuplicateSheetNames( false ) > 0 )
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet." ) );
|
|
|
|
retVal = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-05 10:33:34 +00:00
|
|
|
SCH_ITEM* item = (SCH_ITEM*) selTool->GetNode( aPosition );
|
2019-04-30 13:54:32 +00:00
|
|
|
|
|
|
|
if( item && item->Connection( *g_CurrentSheet ) )
|
|
|
|
netName = item->Connection( *g_CurrentSheet )->Name();
|
2019-04-14 00:44:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-04 20:18:41 +00:00
|
|
|
if( netName.empty() )
|
|
|
|
{
|
|
|
|
editFrame->SetStatusText( wxT( "" ) );
|
|
|
|
editFrame->SendCrossProbeClearHighlight();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
editFrame->SendCrossProbeNetName( netName );
|
2019-04-30 13:54:32 +00:00
|
|
|
editFrame->SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
|
2019-05-16 21:58:47 +00:00
|
|
|
UnescapeString( netName ) ) );
|
2019-05-04 20:18:41 +00:00
|
|
|
}
|
|
|
|
|
2019-04-14 00:44:05 +00:00
|
|
|
editFrame->SetSelectedNetName( netName );
|
2019-05-10 23:13:40 +00:00
|
|
|
TOOL_EVENT dummy;
|
2019-05-12 17:03:17 +00:00
|
|
|
editorControl->UpdateNetHighlighting( dummy );
|
2019-04-14 00:44:05 +00:00
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::HighlightNet( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
2019-04-30 13:54:32 +00:00
|
|
|
VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
|
2019-04-14 00:44:05 +00:00
|
|
|
|
2019-04-30 13:54:32 +00:00
|
|
|
highlightNet( m_toolMgr, cursorPos );
|
2019-04-14 00:44:05 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-21 23:45:34 +00:00
|
|
|
int SCH_EDITOR_CONTROL::ClearHighlight( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
highlightNet( m_toolMgr, CLEAR );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-12 17:03:17 +00:00
|
|
|
int SCH_EDITOR_CONTROL::UpdateNetHighlighting( const TOOL_EVENT& aEvent )
|
2019-04-14 00:44:05 +00:00
|
|
|
{
|
|
|
|
SCH_SCREEN* screen = g_CurrentSheet->LastScreen();
|
|
|
|
std::vector<EDA_ITEM*> itemsToRedraw;
|
|
|
|
wxString selectedNetName = m_frame->GetSelectedNetName();
|
|
|
|
|
|
|
|
if( !screen )
|
|
|
|
return 0;
|
|
|
|
|
2019-04-19 16:15:14 +00:00
|
|
|
for( SCH_ITEM* item = screen->GetDrawItems(); item; item = item->Next() )
|
2019-04-14 00:44:05 +00:00
|
|
|
{
|
2019-04-19 16:15:14 +00:00
|
|
|
SCH_CONNECTION* conn = item->Connection( *g_CurrentSheet );
|
|
|
|
bool redraw = item->IsBrightened();
|
2019-04-14 00:44:05 +00:00
|
|
|
|
2019-04-19 16:15:14 +00:00
|
|
|
if( conn && conn->Name() == selectedNetName )
|
|
|
|
item->SetBrightened();
|
|
|
|
else
|
|
|
|
item->ClearBrightened();
|
2019-04-14 00:44:05 +00:00
|
|
|
|
2019-04-19 16:15:14 +00:00
|
|
|
redraw |= item->IsBrightened();
|
2019-04-14 00:44:05 +00:00
|
|
|
|
2019-04-19 16:15:14 +00:00
|
|
|
if( item->Type() == SCH_COMPONENT_T )
|
2019-04-14 00:44:05 +00:00
|
|
|
{
|
2019-04-19 16:15:14 +00:00
|
|
|
SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( item );
|
2019-04-14 00:44:05 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-19 16:15:14 +00:00
|
|
|
else if( item->Type() == SCH_SHEET_T )
|
2019-04-14 00:44:05 +00:00
|
|
|
{
|
2019-04-19 16:15:14 +00:00
|
|
|
for( SCH_SHEET_PIN& pin : static_cast<SCH_SHEET*>( item )->GetPins() )
|
2019-04-14 00:44:05 +00:00
|
|
|
{
|
|
|
|
auto pin_conn = pin.Connection( *g_CurrentSheet );
|
2019-04-19 16:15:14 +00:00
|
|
|
bool redrawPin = pin.IsBrightened();
|
2019-04-14 00:44:05 +00:00
|
|
|
|
2019-04-19 16:15:14 +00:00
|
|
|
if( pin_conn && pin_conn->Name() == selectedNetName )
|
|
|
|
pin.SetBrightened();
|
|
|
|
else
|
|
|
|
pin.ClearBrightened();
|
2019-04-14 00:44:05 +00:00
|
|
|
|
2019-04-19 16:15:14 +00:00
|
|
|
redrawPin |= pin.IsBrightened();
|
2019-04-14 00:44:05 +00:00
|
|
|
|
|
|
|
if( redrawPin )
|
|
|
|
itemsToRedraw.push_back( &pin );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( redraw )
|
2019-04-19 16:15:14 +00:00
|
|
|
itemsToRedraw.push_back( item );
|
2019-04-14 00:44:05 +00:00
|
|
|
}
|
|
|
|
|
2019-08-20 17:22:30 +00:00
|
|
|
// Be sure highlight change will be redrawn
|
2019-04-14 00:44:05 +00:00
|
|
|
KIGFX::VIEW* view = getView();
|
|
|
|
|
2019-04-19 16:15:14 +00:00
|
|
|
for( auto redrawItem : itemsToRedraw )
|
|
|
|
view->Update( (KIGFX::VIEW_ITEM*)redrawItem, KIGFX::VIEW_UPDATE_FLAGS::REPAINT );
|
2019-04-14 00:44:05 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
m_frame->GetCanvas()->Refresh();
|
2019-04-14 00:44:05 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-04-15 23:56:41 +00:00
|
|
|
// TODO(JE) remove once real-time connectivity is a given
|
2019-04-29 21:44:49 +00:00
|
|
|
if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
|
2019-04-15 23:56:41 +00:00
|
|
|
m_frame->RecalculateConnections();
|
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
|
|
|
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
2019-07-09 14:01:43 +00:00
|
|
|
|
2019-07-19 20:47:33 +00:00
|
|
|
// Deactivate other tools; particularly important if another PICKER is currently running
|
|
|
|
Activate();
|
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
|
2019-04-14 00:44:05 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
picker->SetClickHandler(
|
2019-07-22 01:06:06 +00:00
|
|
|
[this] ( const VECTOR2D& aPos )
|
2019-07-15 23:44:01 +00:00
|
|
|
{
|
|
|
|
return highlightNet( m_toolMgr, aPos );
|
|
|
|
} );
|
|
|
|
|
|
|
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
2019-07-15 12:15:58 +00:00
|
|
|
|
2019-04-14 00:44:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
int SCH_EDITOR_CONTROL::Undo( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
if( m_frame->GetScreen()->GetUndoCommandCount() <= 0 )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// Inform tools that undo command was issued
|
|
|
|
m_toolMgr->ProcessEvent( { TC_MESSAGE, TA_UNDO_REDO_PRE, AS_GLOBAL } );
|
|
|
|
|
|
|
|
/* Get the old list */
|
|
|
|
PICKED_ITEMS_LIST* List = m_frame->GetScreen()->PopCommandFromUndoList();
|
|
|
|
|
|
|
|
/* Undo the command */
|
|
|
|
m_frame->PutDataInPreviousState( List, false );
|
|
|
|
|
|
|
|
/* Put the old list in RedoList */
|
|
|
|
List->ReversePickersListOrder();
|
|
|
|
m_frame->GetScreen()->PushCommandToRedoList( List );
|
|
|
|
|
2019-06-29 18:57:23 +00:00
|
|
|
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
selTool->RebuildSelection();
|
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
m_frame->SetSheetNumberAndCount();
|
|
|
|
m_frame->TestDanglingEnds();
|
|
|
|
|
|
|
|
m_frame->SyncView();
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
m_frame->OnModify();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::Redo( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
if( m_frame->GetScreen()->GetRedoCommandCount() == 0 )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// Inform tools that undo command was issued
|
|
|
|
m_toolMgr->ProcessEvent( { TC_MESSAGE, TA_UNDO_REDO_PRE, AS_GLOBAL } );
|
|
|
|
|
|
|
|
/* Get the old list */
|
|
|
|
PICKED_ITEMS_LIST* List = m_frame->GetScreen()->PopCommandFromRedoList();
|
|
|
|
|
|
|
|
/* Redo the command: */
|
|
|
|
m_frame->PutDataInPreviousState( List, true );
|
|
|
|
|
|
|
|
/* Put the old list in UndoList */
|
|
|
|
List->ReversePickersListOrder();
|
|
|
|
m_frame->GetScreen()->PushCommandToUndoList( List );
|
|
|
|
|
2019-06-29 18:57:23 +00:00
|
|
|
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
selTool->RebuildSelection();
|
2019-05-14 19:21:10 +00:00
|
|
|
|
2019-06-29 18:57:23 +00:00
|
|
|
m_frame->SetSheetNumberAndCount();
|
2019-05-14 19:21:10 +00:00
|
|
|
m_frame->TestDanglingEnds();
|
|
|
|
|
|
|
|
m_frame->SyncView();
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
m_frame->OnModify();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-28 16:36:31 +00:00
|
|
|
bool SCH_EDITOR_CONTROL::doCopy()
|
|
|
|
{
|
2019-05-10 17:19:48 +00:00
|
|
|
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
2019-07-09 20:38:18 +00:00
|
|
|
EE_SELECTION& selection = selTool->RequestSelection();
|
2019-04-28 16:36:31 +00:00
|
|
|
|
|
|
|
if( !selection.GetSize() )
|
|
|
|
return false;
|
|
|
|
|
2019-08-30 20:55:04 +00:00
|
|
|
m_supplementaryClipboard.clear();
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
if( item->Type() == SCH_SHEET_T )
|
|
|
|
{
|
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
|
|
|
m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-28 16:36:31 +00:00
|
|
|
STRING_FORMATTER formatter;
|
|
|
|
SCH_LEGACY_PLUGIN plugin;
|
|
|
|
|
|
|
|
plugin.Format( &selection, &formatter );
|
|
|
|
|
|
|
|
return m_toolMgr->SaveClipboard( formatter.GetString() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-30 20:55:04 +00:00
|
|
|
bool SCH_EDITOR_CONTROL::searchSupplementaryClipboard( const wxString& aSheetFilename,
|
|
|
|
SCH_SCREEN** aScreen )
|
|
|
|
{
|
|
|
|
if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
|
|
|
|
{
|
|
|
|
*aScreen = m_supplementaryClipboard[ aSheetFilename ];
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-28 16:36:31 +00:00
|
|
|
int SCH_EDITOR_CONTROL::Cut( const TOOL_EVENT& aEvent )
|
2019-04-23 13:06:37 +00:00
|
|
|
{
|
2019-08-08 10:12:04 +00:00
|
|
|
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
|
|
|
|
|
|
|
|
if( textEntry )
|
|
|
|
{
|
|
|
|
textEntry->Cut();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-04-28 16:36:31 +00:00
|
|
|
if( doCopy() )
|
2019-07-31 12:48:00 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::doDelete, true );
|
2019-04-28 16:36:31 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::Copy( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-08-08 10:12:04 +00:00
|
|
|
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
|
|
|
|
|
|
|
|
if( textEntry )
|
|
|
|
{
|
|
|
|
textEntry->Copy();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-04-28 16:36:31 +00:00
|
|
|
doCopy();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-08-08 10:12:04 +00:00
|
|
|
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
|
|
|
|
|
|
|
|
if( textEntry )
|
|
|
|
{
|
|
|
|
textEntry->Paste();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
2019-04-28 16:36:31 +00:00
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
DLIST<SCH_ITEM>& dlist = m_frame->GetScreen()->GetDrawList();
|
2019-09-02 18:23:46 +00:00
|
|
|
SCH_ITEM* lastExisting = dlist.GetLast();
|
2019-04-28 16:36:31 +00:00
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
std::string text = m_toolMgr->GetClipboard();
|
2019-08-15 07:19:15 +00:00
|
|
|
|
|
|
|
if( text.empty() )
|
|
|
|
return 0;
|
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
STRING_LINE_READER reader( text, "Clipboard" );
|
|
|
|
SCH_LEGACY_PLUGIN plugin;
|
2019-04-28 16:36:31 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
plugin.LoadContent( reader, m_frame->GetScreen() );
|
|
|
|
}
|
|
|
|
catch( IO_ERROR& e )
|
|
|
|
{
|
2019-08-15 07:19:15 +00:00
|
|
|
// If it wasn't content, then paste as text
|
|
|
|
dlist.Append( new SCH_TEXT( wxPoint( 0, 0 ), text ) );
|
2019-04-28 16:36:31 +00:00
|
|
|
}
|
|
|
|
|
2019-09-02 18:23:46 +00:00
|
|
|
bool forceKeepAnnotations = false;
|
|
|
|
bool forceDropAnnotations = false;
|
|
|
|
bool dropAnnotations = false;
|
|
|
|
|
|
|
|
if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
|
|
|
|
{
|
|
|
|
DIALOG_PASTE_SPECIAL dlg( m_frame, &forceKeepAnnotations, &forceDropAnnotations );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( forceDropAnnotations )
|
|
|
|
dropAnnotations = true;
|
|
|
|
|
2019-04-28 16:36:31 +00:00
|
|
|
// SCH_LEGACY_PLUGIN added the items to the DLIST, but not to the view or anything
|
|
|
|
// else. Pull them back out to start with.
|
|
|
|
//
|
2019-09-02 18:23:46 +00:00
|
|
|
SCH_ITEM* firstNew = lastExisting ? lastExisting->Next() : dlist.GetFirst();
|
|
|
|
EDA_ITEMS loadedItems;
|
|
|
|
SCH_ITEM* next = nullptr;
|
2019-04-23 13:06:37 +00:00
|
|
|
|
2019-05-03 11:49:59 +00:00
|
|
|
bool sheetsPasted = false;
|
2019-04-28 16:36:31 +00:00
|
|
|
SCH_SHEET_LIST hierarchy( g_RootSheet );
|
|
|
|
wxFileName destFn = g_CurrentSheet->Last()->GetFileName();
|
2019-04-23 13:06:37 +00:00
|
|
|
|
2019-04-28 16:36:31 +00:00
|
|
|
if( destFn.IsRelative() )
|
|
|
|
destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
|
|
|
|
|
2019-09-02 18:23:46 +00:00
|
|
|
for( SCH_ITEM* item = firstNew; item; item = next )
|
2019-04-23 13:06:37 +00:00
|
|
|
{
|
2019-04-28 16:36:31 +00:00
|
|
|
next = item->Next();
|
|
|
|
dlist.Remove( item );
|
|
|
|
|
|
|
|
loadedItems.push_back( item );
|
|
|
|
|
|
|
|
if( item->Type() == SCH_COMPONENT_T )
|
2019-04-23 13:06:37 +00:00
|
|
|
{
|
2019-09-02 18:23:46 +00:00
|
|
|
if( !dropAnnotations && !forceKeepAnnotations )
|
|
|
|
{
|
|
|
|
for( SCH_ITEM* temp = dlist.GetFirst(); temp != lastExisting; temp = temp->Next() )
|
|
|
|
{
|
|
|
|
if( item->GetTimeStamp() == temp->GetTimeStamp() )
|
|
|
|
dropAnnotations = true;
|
|
|
|
}
|
|
|
|
}
|
2019-04-23 13:06:37 +00:00
|
|
|
}
|
2019-09-02 18:23:46 +00:00
|
|
|
else if( item->Type() == SCH_SHEET_T )
|
2019-04-23 13:06:37 +00:00
|
|
|
{
|
2019-04-28 16:36:31 +00:00
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
|
|
|
wxFileName srcFn = sheet->GetFileName();
|
|
|
|
|
|
|
|
if( srcFn.IsRelative() )
|
|
|
|
srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
|
|
|
|
|
|
|
|
SCH_SHEET_LIST sheetHierarchy( sheet );
|
|
|
|
|
|
|
|
if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
|
|
|
|
{
|
|
|
|
auto msg = wxString::Format( _( "The pasted sheet \"%s\"\n"
|
|
|
|
"was dropped because the destination already has "
|
|
|
|
"the sheet or one of its subsheets as a parent." ),
|
|
|
|
sheet->GetFileName() );
|
|
|
|
DisplayError( m_frame, msg );
|
|
|
|
loadedItems.pop_back();
|
|
|
|
}
|
2019-04-23 13:06:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-28 16:36:31 +00:00
|
|
|
// Now we can resolve the components and add everything to the screen, view, etc.
|
|
|
|
//
|
|
|
|
SYMBOL_LIB_TABLE* symLibTable = m_frame->Prj().SchSymbolLibTable();
|
|
|
|
PART_LIB* partLib = m_frame->Prj().SchLibs()->GetCacheLibrary();
|
2019-04-23 13:06:37 +00:00
|
|
|
|
2019-05-11 09:12:39 +00:00
|
|
|
for( unsigned i = 0; i < loadedItems.size(); ++i )
|
2019-04-28 16:36:31 +00:00
|
|
|
{
|
2019-05-03 22:46:44 +00:00
|
|
|
EDA_ITEM* item = loadedItems[i];
|
2019-04-23 13:06:37 +00:00
|
|
|
|
2019-04-28 16:36:31 +00:00
|
|
|
if( item->Type() == SCH_COMPONENT_T )
|
|
|
|
{
|
|
|
|
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
|
2019-09-02 18:23:46 +00:00
|
|
|
|
|
|
|
if( dropAnnotations )
|
|
|
|
{
|
|
|
|
component->SetTimeStamp( GetNewTimeStamp() );
|
|
|
|
|
|
|
|
// clear the annotation, but preserve the selected unit
|
|
|
|
int unit = component->GetUnit();
|
|
|
|
component->ClearAnnotation( nullptr );
|
|
|
|
component->SetUnit( unit );
|
|
|
|
}
|
|
|
|
|
2019-04-28 16:36:31 +00:00
|
|
|
component->Resolve( *symLibTable, partLib );
|
2019-08-16 14:31:53 +00:00
|
|
|
component->UpdatePins();
|
2019-04-28 16:36:31 +00:00
|
|
|
}
|
2019-05-03 11:49:59 +00:00
|
|
|
else if( item->Type() == SCH_SHEET_T )
|
|
|
|
{
|
2019-06-12 13:23:53 +00:00
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
2019-06-26 01:44:00 +00:00
|
|
|
wxFileName fn = sheet->GetFileName();
|
2019-06-12 13:23:53 +00:00
|
|
|
SCH_SCREEN* existingScreen = nullptr;
|
2019-09-02 18:23:46 +00:00
|
|
|
bool dropSheetAnnotations = false;
|
|
|
|
|
|
|
|
// Duplicate sheet names and timestamps are not valid. Generate new timestamps
|
|
|
|
// and timestamp-based sheet names.
|
|
|
|
timestamp_t uid = GetNewTimeStamp();
|
|
|
|
|
|
|
|
sheet->SetName( wxString::Format( wxT( "sheet%8.8lX" ), (unsigned long)uid ) );
|
|
|
|
sheet->SetTimeStamp( uid );
|
|
|
|
sheet->SetParent( g_CurrentSheet->Last() );
|
|
|
|
sheet->SetScreen( nullptr );
|
|
|
|
sheetsPasted = true;
|
2019-06-12 13:23:53 +00:00
|
|
|
|
2019-06-26 01:44:00 +00:00
|
|
|
if( !fn.IsAbsolute() )
|
|
|
|
{
|
|
|
|
wxFileName currentSheetFileName = g_CurrentSheet->LastScreen()->GetFileName();
|
|
|
|
fn.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() );
|
|
|
|
}
|
|
|
|
|
2019-09-02 18:23:46 +00:00
|
|
|
if( g_RootSheet->SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ), &existingScreen ) )
|
|
|
|
dropSheetAnnotations = true;
|
|
|
|
else
|
|
|
|
searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen );
|
|
|
|
|
|
|
|
if( existingScreen )
|
2019-06-26 01:44:00 +00:00
|
|
|
{
|
2019-06-12 13:23:53 +00:00
|
|
|
sheet->SetScreen( existingScreen );
|
2019-06-26 01:44:00 +00:00
|
|
|
|
|
|
|
SCH_SHEET_PATH sheetpath = *g_CurrentSheet;
|
|
|
|
sheetpath.push_back( sheet );
|
|
|
|
|
|
|
|
// Clear annotation and create the AR for this path, if not exists,
|
|
|
|
// when the screen is shared by sheet paths.
|
|
|
|
// Otherwise ClearAnnotation do nothing, because the F1 field is used as
|
|
|
|
// reference default value and takes the latest displayed value
|
|
|
|
existingScreen->EnsureAlternateReferencesExist();
|
2019-09-02 18:23:46 +00:00
|
|
|
|
|
|
|
if( forceDropAnnotations || dropSheetAnnotations )
|
|
|
|
existingScreen->ClearAnnotation( &sheetpath );
|
2019-06-26 01:44:00 +00:00
|
|
|
}
|
2019-06-12 13:23:53 +00:00
|
|
|
else
|
2019-06-26 01:44:00 +00:00
|
|
|
{
|
2019-08-29 22:25:52 +00:00
|
|
|
if( !m_frame->LoadSheetFromFile( sheet, g_CurrentSheet, fn.GetFullPath() ) )
|
|
|
|
m_frame->InitSheet( sheet, sheet->GetFileName() );
|
2019-06-26 01:44:00 +00:00
|
|
|
}
|
2019-05-03 11:49:59 +00:00
|
|
|
}
|
2019-04-23 13:06:37 +00:00
|
|
|
|
2019-05-16 22:50:54 +00:00
|
|
|
item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
|
2019-05-03 22:46:44 +00:00
|
|
|
m_frame->AddItemToScreenAndUndoList( (SCH_ITEM*) item, i > 0 );
|
2019-05-06 15:58:53 +00:00
|
|
|
|
|
|
|
// Reset flags for subsequent move operation
|
2019-05-16 22:50:54 +00:00
|
|
|
item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
|
2019-08-29 22:55:25 +00:00
|
|
|
// Start out hidden so the pasted items aren't "ghosted" in their original location
|
|
|
|
// before being moved to the current location.
|
|
|
|
getView()->Hide( item, true );
|
2019-04-28 16:36:31 +00:00
|
|
|
}
|
2019-04-23 13:06:37 +00:00
|
|
|
|
2019-05-03 11:49:59 +00:00
|
|
|
if( sheetsPasted )
|
|
|
|
m_frame->SetSheetNumberAndCount();
|
2019-04-28 16:36:31 +00:00
|
|
|
|
|
|
|
// Now clear the previous selection, select the pasted items, and fire up the "move"
|
|
|
|
// tool.
|
|
|
|
//
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
|
2019-04-28 16:36:31 +00:00
|
|
|
|
2019-06-08 21:48:22 +00:00
|
|
|
EE_SELECTION& selection = selTool->GetSelection();
|
2019-04-28 16:36:31 +00:00
|
|
|
|
|
|
|
if( !selection.Empty() )
|
|
|
|
{
|
|
|
|
SCH_ITEM* item = (SCH_ITEM*) selection.GetTopLeftItem();
|
|
|
|
|
|
|
|
selection.SetReferencePoint( item->GetPosition() );
|
2019-05-10 17:19:48 +00:00
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::move, false );
|
2019-04-28 16:36:31 +00:00
|
|
|
}
|
2019-04-23 13:06:37 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-17 15:44:58 +00:00
|
|
|
int SCH_EDITOR_CONTROL::EditWithLibEdit( const TOOL_EVENT& aEvent )
|
2019-04-29 22:24:30 +00:00
|
|
|
{
|
2019-05-10 17:19:48 +00:00
|
|
|
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
2019-06-08 21:48:22 +00:00
|
|
|
EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::ComponentsOnly );
|
2019-06-06 11:45:28 +00:00
|
|
|
SCH_COMPONENT* sym = nullptr;
|
|
|
|
LIB_EDIT_FRAME* libEdit;
|
2019-04-29 22:24:30 +00:00
|
|
|
|
|
|
|
if( selection.GetSize() >= 1 )
|
2019-06-06 11:45:28 +00:00
|
|
|
sym = (SCH_COMPONENT*) selection.Front();
|
2019-04-29 22:24:30 +00:00
|
|
|
|
2019-06-06 11:45:28 +00:00
|
|
|
if( !sym || sym->GetEditFlags() != 0 )
|
2019-04-29 22:24:30 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-06-06 11:45:28 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::showSymbolEditor, true );
|
|
|
|
libEdit = (LIB_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
|
2019-04-29 22:24:30 +00:00
|
|
|
|
2019-06-06 11:45:28 +00:00
|
|
|
if( libEdit )
|
|
|
|
libEdit->LoadComponentAndSelectLib( sym->GetLibId(), sym->GetUnit(), sym->GetConvert() );
|
2019-04-29 22:24:30 +00:00
|
|
|
|
2019-05-13 20:42:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-01 15:28:39 +00:00
|
|
|
int SCH_EDITOR_CONTROL::Annotate( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
m_frame->OnAnnotate( dummy );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::ShowCvpcb( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
m_frame->OnOpenCvpcb( dummy );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::EditSymbolFields( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
DIALOG_FIELDS_EDITOR_GLOBAL dlg( m_frame );
|
|
|
|
dlg.ShowQuasiModal();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-01 18:36:49 +00:00
|
|
|
int SCH_EDITOR_CONTROL::EditSymbolLibraryLinks( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-07-09 11:38:10 +00:00
|
|
|
if( InvokeDialogEditComponentsLibId( m_frame ) )
|
|
|
|
m_frame->HardRedraw();
|
|
|
|
|
2019-06-01 18:36:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-01 15:28:39 +00:00
|
|
|
int SCH_EDITOR_CONTROL::ShowPcbNew( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
m_frame->OnOpenPcbnew( dummy );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::UpdatePCB( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
m_frame->OnUpdatePCB( dummy );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-16 13:42:40 +00:00
|
|
|
int SCH_EDITOR_CONTROL::ExportNetlist( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
int result = NET_PLUGIN_CHANGE;
|
|
|
|
|
|
|
|
// If a plugin is removed or added, rebuild and reopen the new dialog
|
|
|
|
while( result == NET_PLUGIN_CHANGE )
|
|
|
|
result = InvokeDialogNetList( m_frame );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-01 15:28:39 +00:00
|
|
|
int SCH_EDITOR_CONTROL::GenerateBOM( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
InvokeDialogCreateBOM( m_frame );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-16 16:07:15 +00:00
|
|
|
int SCH_EDITOR_CONTROL::DrawSheetOnClipboard( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->DrawCurrentSheetToClipboard();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-01 15:28:39 +00:00
|
|
|
int SCH_EDITOR_CONTROL::ShowBusManager( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
InvokeDialogBusManager( m_frame );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-30 14:46:29 +00:00
|
|
|
int SCH_EDITOR_CONTROL::EnterSheet( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-06-08 21:48:22 +00:00
|
|
|
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
|
2019-04-30 14:46:29 +00:00
|
|
|
|
|
|
|
if( selection.GetSize() == 1 )
|
|
|
|
{
|
2019-06-13 21:04:31 +00:00
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
|
|
|
|
|
|
|
|
m_toolMgr->RunAction( ACTIONS::cancelInteractive, true );
|
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
|
|
|
|
|
|
|
g_CurrentSheet->push_back( sheet );
|
2019-04-30 14:46:29 +00:00
|
|
|
m_frame->DisplayCurrentSheet();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDITOR_CONTROL::LeaveSheet( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
if( g_CurrentSheet->Last() != g_RootSheet )
|
|
|
|
{
|
2019-06-13 21:04:31 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::cancelInteractive, true );
|
|
|
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
|
|
|
|
2019-04-30 14:46:29 +00:00
|
|
|
g_CurrentSheet->pop_back();
|
|
|
|
m_frame->DisplayCurrentSheet();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-13 20:42:40 +00:00
|
|
|
int SCH_EDITOR_CONTROL::ToggleHiddenPins( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->SetShowAllPins( !m_frame->GetShowAllPins() );
|
|
|
|
|
|
|
|
auto painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
|
|
|
|
painter->GetSettings()->m_ShowHiddenPins = m_frame->GetShowAllPins();
|
|
|
|
|
|
|
|
getView()->UpdateAllItems( KIGFX::REPAINT );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-13 21:49:05 +00:00
|
|
|
int SCH_EDITOR_CONTROL::ToggleForceHV( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->SetForceHVLines( !m_frame->GetForceHVLines() );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-14 00:44:05 +00:00
|
|
|
void SCH_EDITOR_CONTROL::setTransitions()
|
|
|
|
{
|
2019-05-24 23:36:31 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::SaveAs, ACTIONS::saveAs.MakeEvent() );
|
2019-05-26 15:36:40 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::PageSetup, ACTIONS::pageSettings.MakeEvent() );
|
2019-05-24 23:36:31 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
|
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::FindAndReplace, ACTIONS::find.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::FindAndReplace, ACTIONS::findAndReplace.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::FindNext, ACTIONS::findNext.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::FindNext, ACTIONS::findNextMarker.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::ReplaceAndFindNext, ACTIONS::replaceAndFindNext.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::ReplaceAll, ACTIONS::replaceAll.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::UpdateFind, ACTIONS::updateFind.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::UpdateFind, EVENTS::SelectedItemsModified );
|
|
|
|
|
2019-04-30 18:36:11 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::CrossProbeToPcb, EVENTS::SelectedEvent );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::CrossProbeToPcb, EVENTS::UnselectedEvent );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::CrossProbeToPcb, EVENTS::ClearedEvent );
|
2019-05-10 17:19:48 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::ExplicitCrossProbeToPcb, EE_ACTIONS::explicitCrossProbe.MakeEvent() );
|
2019-04-29 21:17:26 +00:00
|
|
|
|
2019-04-23 17:12:26 +00:00
|
|
|
#ifdef KICAD_SPICE
|
2019-05-10 17:19:48 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::SimProbe, EE_ACTIONS::simProbe.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::SimTune, EE_ACTIONS::simTune.MakeEvent() );
|
2019-04-23 17:12:26 +00:00
|
|
|
#endif /* KICAD_SPICE */
|
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::HighlightNet, EE_ACTIONS::highlightNet.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::ClearHighlight, EE_ACTIONS::clearHighlight.MakeEvent() );
|
2019-07-26 15:28:59 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::HighlightNetCursor, EE_ACTIONS::highlightNetTool.MakeEvent() );
|
2019-05-12 17:03:17 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::UpdateNetHighlighting, EVENTS::SelectedItemsModified );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::UpdateNetHighlighting, EE_ACTIONS::updateNetHighlighting.MakeEvent() );
|
2019-06-27 11:47:24 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::ClearHighlight, ACTIONS::cancelInteractive.MakeEvent() );
|
2019-04-23 13:06:37 +00:00
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
|
2019-09-02 18:23:46 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::Paste, ACTIONS::pasteSpecial.MakeEvent() );
|
2019-04-29 22:24:30 +00:00
|
|
|
|
2019-05-17 15:44:58 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::EditWithLibEdit, EE_ACTIONS::editWithLibEdit.MakeEvent() );
|
2019-06-01 15:28:39 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::ShowCvpcb, EE_ACTIONS::assignFootprints.MakeEvent() );
|
2019-06-16 16:07:15 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::ImportFPAssignments, EE_ACTIONS::importFPAssignments.MakeEvent() );
|
2019-06-01 15:28:39 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::Annotate, EE_ACTIONS::annotate.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::EditSymbolFields, EE_ACTIONS::editSymbolFields.MakeEvent() );
|
2019-06-01 18:36:49 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::EditSymbolLibraryLinks,EE_ACTIONS::editSymbolLibraryLinks.MakeEvent() );
|
2019-06-01 15:28:39 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::ShowPcbNew, EE_ACTIONS::showPcbNew.MakeEvent() );
|
2019-06-03 13:49:17 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::UpdatePCB, ACTIONS::updatePcbFromSchematic.MakeEvent() );
|
2019-06-16 13:42:40 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::ExportNetlist, EE_ACTIONS::exportNetlist.MakeEvent() );
|
2019-06-01 15:28:39 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::GenerateBOM, EE_ACTIONS::generateBOM.MakeEvent() );
|
2019-06-16 16:07:15 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::DrawSheetOnClipboard, EE_ACTIONS::drawSheetOnClipboard.MakeEvent() );
|
2019-06-01 15:28:39 +00:00
|
|
|
|
|
|
|
Go( &SCH_EDITOR_CONTROL::ShowBusManager, EE_ACTIONS::showBusManager.MakeEvent() );
|
2019-04-30 14:46:29 +00:00
|
|
|
|
2019-05-10 17:19:48 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::EnterSheet, EE_ACTIONS::enterSheet.MakeEvent() );
|
|
|
|
Go( &SCH_EDITOR_CONTROL::LeaveSheet, EE_ACTIONS::leaveSheet.MakeEvent() );
|
2019-05-13 20:42:40 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::NavigateHierarchy, EE_ACTIONS::navigateHierarchy.MakeEvent() );
|
|
|
|
|
|
|
|
Go( &SCH_EDITOR_CONTROL::ToggleHiddenPins, EE_ACTIONS::toggleHiddenPins.MakeEvent() );
|
2019-05-13 21:49:05 +00:00
|
|
|
Go( &SCH_EDITOR_CONTROL::ToggleForceHV, EE_ACTIONS::toggleForceHV.MakeEvent() );
|
2019-04-14 00:44:05 +00:00
|
|
|
}
|